Page 1 of 1

Multidimensional $_POST

Posted: Thu Oct 22, 2009 4:50 pm
by tua1
Hello

How to get a single array from array of array (2 - dimension).
For example I have a form:

Code: Select all

 
    <input type="text" name="[b]personal[name][/b]" id="name" maxlength="50" value="Kasia"/>
    <input type="text" name="[b]personal[surname][/b]" id="surname" maxlength="50" value="Nova"/>
       //etc...other input fields with different array
 
In my php code I want to take, an array personal form $_POST and assign it to new variable:

Code: Select all

 
$personal_array = $_POST['personal'];
$another_array = $_POST['other']
etc...
 
But it doesn't work
Could anybody help me?

Regards

Re: Multidimensional $_POST

Posted: Thu Oct 22, 2009 4:53 pm
by John Cartwright
Try

Code: Select all

var_dump($_POST);
to see exactly how the array is organized. Basically, with your example,

Code: Select all

$personal_array = $_POST['personal'];
echo $personal_array['name']; // $_POST['personal']['name']

Re: Multidimensional $_POST

Posted: Fri Oct 23, 2009 4:46 am
by tua1
Thanks for your help, that's was so easy :mrgreen: