Multidimensional $_POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tua1
Forum Commoner
Posts: 28
Joined: Thu May 15, 2008 9:30 pm

Multidimensional $_POST

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Multidimensional $_POST

Post 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']
tua1
Forum Commoner
Posts: 28
Joined: Thu May 15, 2008 9:30 pm

Re: Multidimensional $_POST

Post by tua1 »

Thanks for your help, that's was so easy :mrgreen:
Post Reply