[Solved] Array Formation – PHP


check this code , guess you want to single array result

check array_reduce () built in function

<?php
$your_array = array(0 => array('item_id' => 3160), 1 => array('item_id' => 13123), 2 => array('item_id' => 234234), 3 => array('item_id' => 2123));
echo "<pre>";
print_r($your_array);
$convert_array = array_map('intval', array_column($your_array, 'item_id'));
echo "<pre>";
print_r($convert_array);

then your original Array :

Array
(
    [0] => Array
        (
            [item_id] => 3160
        )

    [1] => Array
        (
            [item_id] => 13123
        )

    [2] => Array
        (
            [item_id] => 234234
        )

    [3] => Array
        (
            [item_id] => 2123
        )

)

and output :

Array
(
    [0] => 3160
    [1] => 13123
    [2] => 234234
    [3] => 2123
)

solved Array Formation – PHP