1885 Posted December 6, 2012 Share Posted December 6, 2012 I am having trouble passing an array from one page to another. I want to do a data submission check and set the intial values to 0. //********************************************************************************************************** page 1: <?php session_start(); $inputs = array(); $v = array(); for($i=0; $i<13; $i++) {$v[$i] = 0; $inputs[$i] = 0; //set inputs to 0 echo "v = $v[$i] "; // debug } $_SESSION['inputs'] = '$inputs'; ?> <html> </html> //********************************************************************************************************** page 2: <?php session_start(); $inputs = $_SESSION['inputs']; //for($i = 0; $i < 13; $i++) echo "$v[$i] -"; for($i = 0; $i < 13; $i++) echo "$inputs[$i] -"; //debug ?> <html> Input 0 <FORM method="post" action="check-inputs.php"> . . . Link to comment https://forums.phpfreaks.com/topic/271673-pass-array-from-on-epage-to-another/ Share on other sites More sharing options...
mikosiko Posted December 6, 2012 Share Posted December 6, 2012 $_SESSION['inputs'] = '$inputs'; variables enclosed in single quotes are not interpolated Link to comment https://forums.phpfreaks.com/topic/271673-pass-array-from-on-epage-to-another/#findComment-1397836 Share on other sites More sharing options...
1885 Posted December 6, 2012 Author Share Posted December 6, 2012 Wow. That was simple. It's been a few years since I've done some php. It's nice to be coding again. Thanks for the help. I'm sure I'll need a lot more! page 1 <?php session_start(); $inputs = array(); $v = array(); for($i=0; $i<13; $i++) {$v[$i] = 0; $inputs[$i] = 0; echo "v = $v[$i] "; } $_SESSION['inputs'] = $inputs; $_SESSION['v'] = $v; ?> <html> page 2 <?php session_start(); $inputs = $_SESSION['inputs']; $v = $_SESSION['v']; for($i = 0; $i < 13; $i++) echo "$v[$i] -"; for($i = 0; $i < 13; $i++) echo "$inputs[$i] -"; ?> <html> Link to comment https://forums.phpfreaks.com/topic/271673-pass-array-from-on-epage-to-another/#findComment-1397839 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.