简体   繁体   中英

key array PHP - Merge key

My problem solve after read this post .. How to remove prefix in array keys

but i've another problem about key array again I've array like this (array multidimentional)

Array([0,123]=> Array ([0]=>value[1]=>value) [1,124]=> Array ([0]=>value[1]=>value) [2,125]=> Array ([0]=>value[1]=>value)

0 is key, 123 is my dummy data .. 0 using for looping and 123 is using too in another purpose

i want to add join 123 and 124 like this ..

before join

[0,123] [1,124] [1,125].....

after join , i want to like this

[0,123,124] [1,125].....

May you know , what should i do ? Do you know solution or advive what function to solve it?

Thankyou so much guys !

You can use array_chunk($array, 3); where $array will be your array and second parameter will be how elements you want in each splitted array..Hope this will help.

For eg.
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));

Output:

Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => c
            [1] => d
        )

    [2] => Array
        (
            [0] => e
        )

)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM