DamienRoche Posted January 6, 2009 Share Posted January 6, 2009 Not sure if I was specific enough up there. Here's what I want to do: I have an array with some values, let's say..... $arr = array('val1','val2','val3'); I want to first save those arrays to a session..... $_SESSION['arr']= $arr; Then I want to refresh......... header("location:".basename(__FILE__)); Then I want to echo then remove one of the values.... echo $arr[0]." has been processed"; $arr = array_diff($arr, $arr[0]); Then I want to repeat until there are no more arrays... I would greatly appreciate any insight into how I can achieve this or if it is even possible. I'd like to put it into a foreach somehow...so the updated array is echoed each time but still redirected...agh, I'm confused. Link to comment https://forums.phpfreaks.com/topic/139727-question-array-val-session-refresh-echo-something-repeat-foreach/ Share on other sites More sharing options...
l_kris06 Posted January 6, 2009 Share Posted January 6, 2009 Heres the code, the second file used here is calles test.php through which we pass the value and u can retrieve that value using GET method. <?php session_start(); $arr = array("one","two"); $_SESSION['arr'] = $arr; //count the number of items in the array; $tot = count($arr); $i = 0; while($i<$tot){ //lets send the array value to the next page for futher manipulation $url = "test.php?arrVal=".$_SESSION['arr'][$i]; header('Location: '.$url); $i++; if($i == $tot){ echo "Completed"; exit; } ?> Link to comment https://forums.phpfreaks.com/topic/139727-question-array-val-session-refresh-echo-something-repeat-foreach/#findComment-731054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.