bpgillett Posted April 16, 2007 Share Posted April 16, 2007 hi. echoing a string in my array from $_POST by numeric position returns nothing; however, referencing it by variable name works. is there a problem referencing an array created from $_POST by numeric position? if so, any way around this? thanks. works: $post = $_POST; echo $post['q1']; doesn't work: $post = $_POST; echo $post[0]; Link to comment https://forums.phpfreaks.com/topic/47315-solved-array-problem/ Share on other sites More sharing options...
Dragen Posted April 16, 2007 Share Posted April 16, 2007 surely $post = $_POST; should be something like $post = $_POST['q1']; Link to comment https://forums.phpfreaks.com/topic/47315-solved-array-problem/#findComment-230811 Share on other sites More sharing options...
Barand Posted April 16, 2007 Share Posted April 16, 2007 $_POST is an associative array whose keys are the names of form fields. If you want to process it as an indexed array you can $post = array_values($_POST); However, if the only reason to do this is to loop through all the values then you can use foreach ($_POST as $value) { echo $value; } Link to comment https://forums.phpfreaks.com/topic/47315-solved-array-problem/#findComment-230827 Share on other sites More sharing options...
bpgillett Posted April 17, 2007 Author Share Posted April 17, 2007 thanks...i feel a little silly. i'm actually manipulating the keys which are dynamically named from another page, so i have to reference them by there numeric position in an indexed array. thanks again. --brian Link to comment https://forums.phpfreaks.com/topic/47315-solved-array-problem/#findComment-230853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.