How to convert submitted form array to this array on php?

Posted by drfanai on Stack Overflow See other posts from Stack Overflow or by drfanai
Published on 2011-11-30T01:28:14Z Indexed on 2011/11/30 1:51 UTC
Read the original article Hit count: 237

Filed under:
|
|

Lets suppose i have the following array submitted by a html form:

array(
    'firstname' => array('Sara','Jim'),
    'lastname'  => array('Gibson','Jobs')
);

What i wanna achieve is the following array:

array(
    array(
        'firstname' => 'sara',
        'lastname'  => 'Gibson'
    ),
    array(
        'firstname' => 'Jim',
        'lastname'  => 'Jim'
    )
);

I need a function to automatically sort the array not manually by entering data but automatically processing array data.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays