I have a session that stores in an array and I was wondering how I would go about if the person visits the same page it doesn't add it to the array and if an array value is empty don't echo the results, this is an example
$SESSION['image'][0] => page1
they visited page1 so it is logged. Now if they go back to the page the array looks like this
$SESSION['image'][0] => page1
$SESSION['image'][1] => page1
Also I echoed out the title and thumbnail image of the last 3 pages visited, but if they have cleared their history or first time visiting the site the images are broken because there is no data in the array. This is what I have tried
if(!empty($_SESSION['image'][1]) {
echo ' <div>$_SESSION[/'image/'][1]</div>
}
I use this to keep the array updating the first 4
if (!isset($_SESSION['image']))
{
$_SESSION['image'] = array();
}
array_unshift($_SESSION['image'], $rentals['Image']);
if (count($_SESSION['image']) > 4)
{
array_pop($rentals['Image']);
}
However is there a better way to just keeping the array at 4 values and dumping the values after 4?
Wow this turned out to a long question, my apologies :-/