1

Below is my multidimensional array.The first index array is data for a user, each sub array contain the properties for a user i.e name, Ideally i want to break this array to have such an array as below.

    Array
(
    [1] => Array
        (
            [0] => Array
                (
                    [First Name] => dahn
                )

            [1] => Array
                (
                    [Event Name] => TESTING OUT THE EVENTBRITE PHP API
                )

            [2] => Array
                (
                    [Last Name] => king
                )

        )

    [2] => Array........

The array i want to be able to generate is as such

    
Array
(
    [0] => Array
        (
            [First Name] => dahn 
            [Event Name] => Testing Out Eventbrite PHP API
            [Last Name] => king
         )

    [1] => Array
        (

Thanks in advance. A link or anything to point me in the right direction will be highly appreciated

4
  • Iterate over the array using a nested foreach loop and create the new array. Commented Apr 6, 2014 at 12:32
  • I can't seem to find the link between the two arrays =,= Commented Apr 6, 2014 at 12:38
  • @I can Has Cheezburger they are not relate just the format i want to produce a similar. Commented Apr 6, 2014 at 12:44
  • @AmalMurali thats the far my am able to nest my foreach ave tried to nest it but i guess there is something am doing thats wrong since...is there away i can play around with php array_map Commented Apr 6, 2014 at 12:47

1 Answer 1

3

Try this:

<?php
function convert($array){
    $new = array();

    foreach($array AS $arr){
        $n = Array();
        foreach($arr as $arr2){
            foreach($arr2 AS $key => $val){
              $n[$key] = $val;

            }
        }
        $new[] = $n;
    }

    return $new;
}
?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.