mardi 4 août 2015

Merge multiple arrays of similar type in PHP

I have one dynamic array with me like this:

$final_array1 = array( 
     '0' => array('title' => 'Title 1','price' => 50,'price_type' => 'fixed'),
     '1' => array('title' => 'Title 2', 'price' => 100, 'price_type' => 'fixed'),
     '2' => array('title' => 'Title 3','price' => 150,'price_type' => 'fixed'),
     '3' => array('title' => 'Title 4', 'price' => 200, 'price_type' => 'fixed')
);

I would like to combine all these array like this:

$final_array = array( 
    array('title' => 'Title 1','price' => 50,'price_type' => 'fixed'),
    array('title' => 'Title 2', 'price' => 100, 'price_type' => 'fixed'),
    array('title' => 'Title 3','price' => 150,'price_type' => 'fixed'),
    array('title' => 'Title 4', 'price' => 200, 'price_type' => 'fixed')
);

How can I do this ?

Aucun commentaire:

Enregistrer un commentaire