Home > Software design >  PHP how to combine array and create new array
PHP how to combine array and create new array

Time:10-29

I have 3 arrays like this :

$first = array(
    [0] => 13
    [1] => 66
    [2] => 15
)

$second = array
(
    [0] => append
    [1] => prepend
    [2] => append
)

$third = array
(
    [0] => 2
    [1] => 4
    [2] => 1
)

Now I want to combine these 3 array and create new SINGLE array like this : I want to get value from each array and combine it into one.

$new_array = array(

    [0] = array (
        'page'=>13,
        'position'=>'append'
        'priority'=>'2'
    )
    [1] = array (
        'page'=>66,
        'position'=>'prepend'
        'priority'=>'4'
    )
    [2] = array (
        'page'=>15,
        'position'=>'append'
        'priority'=>'1'
    )
)

How to do this ?

CodePudding user response:

You can use enter image description here

  • Related