user1080247
user1080247

Reputation: 1166

convert multi-dimensional associated array to be indexed array

i have multi-multidimensional array result with many arrays inside ( associative arrays) and i want to replace the inside arrays to be indexed arrays the original array result like this :

Data Saved: Array
(
    [0] => Array
        (
            [fullname] => john
            [ServiceDescAR] => description
            [user_id] => 13
            [pos] => 29.958040,30.915489
            [icon] => http://maps.google.com/mapfiles/ms/icons/green.png
            [distance] => 0.00460411726624673
        )

    [1] => Array
        (
            [fullname] => angel
            [ServiceDescAR] => description
            [user_id] => 11
            [pos] => 29.958042,30.915478
            [icon] => http://maps.google.com/mapfiles/ms/icons/green.png
            [distance] => 0.005705603509640217
        )

)

and i want to replace all keys to be indexed, it will be like this how to do that

Data Saved: Array
(
    [0] => Array
        (
            [1] => john
            [2] => description 
            [3] => 13
            [4] => 29.958040,30.915489
            [5] => http://maps.google.com/mapfiles/ms/icons/green.png
            [6] => 0.00460411726624673
        )

    [1] => Array
        (
            [1] => angel
            [2] => description 
            [3] => 11
            [4] => 29.958042,30.915478
            [5] => http://maps.google.com/mapfiles/ms/icons/green.png
            [6] => 0.005705603509640217
        )

)

Upvotes: 1

Views: 78

Answers (1)

aghidini
aghidini

Reputation: 3010

You can use array_values to extract all values from array (without the keys):

$result = array_map('array_values', $inputArray);

The resulting inner arrays indices will be zero-based.

Upvotes: 3

Related Questions