I'm creating forms and input boxes on a page dynamically, and passing the inputs with an array to another page. The only problem is, once I get the array, I don't know how to read it! I know how to read a basic array, but the problem is my index is always different:
Array ( [index1_23] => [index2_23] => [index3_23] => [indext4_23] => [index5_23] =>7 [index1_24] => [index2_24] => [index3_24] => [indext4_24] => [index5_24] =>15 )
What I want to do is parse through this with PHP (i'm assuming) so that I can pull the index as a variable, and the ID at the end as a variable.
Ultimately what I want to break out into variable is:
$index = $_POST['index1_']
$id = $_POST['23']
Unfortunatley I can't seem to find an example to tell me how to just read the beginning of the array, and then the end.
Hope this make sense and thanks in advance!
Parsing through a dynamically created array
Started by newphp, Oct 17 2010 11:57 AM
2 replies to this topic
#1
Posted 17 October 2010 - 11:57 AM
|
|
|
#2
Posted 17 October 2010 - 02:05 PM
easiest is to run through the array with a
now you can treat the key as a normal variable and look for parts of the string, and act according to the key or the value...
foreach ((array)$_POST as $key => $val)then, inside this loop, you get the key for each part in $key, and the value in $val
now you can treat the key as a normal variable and look for parts of the string, and act according to the key or the value...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#3
Posted 18 October 2010 - 08:10 AM
Thanks! I'll give that a try!


Sign In
Create Account

Back to top









