Hello, I am trying to come up with a way so a series of random images will only appear once using sessions. I've been struggling with this for awhile and I just can't figure out how to do this. so maybe like when an Image first showed up I would have $_SESSION[$random_image] = 1; //1 representing that it has been viewed However I don't know where to go from there, any ideas? Thank You!
if(empty($_SESSION['in_progress'])) { $_SESSION['in_progress'] = 1; $_SESSION['images'] = generate_images(); } if(count($_SESSION['images']) > 0) { work_with(array_pop($_SESSION['images'])); } Code (markup):
joebert your script is almost right You can try this $list = array();//Your list of files foreach($_SESSION['shown'] as $v){ unset($list[$v]); } //Then select a random file $toshow = current($list); $_SESSION['shown'][$toshow] = $toshow; //Mark as shown Code (markup):