-1

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 !

Community
  • 1
  • 1
TARA
  • 529
  • 1
  • 6
  • 23

1 Answers1

2

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
        )

)
Prashant M Bhavsar
  • 1,136
  • 9
  • 13
  • Oh .. i just know about array chunk .. i want search more again about array chunk .. Thankyou so much@prashant .. – TARA Feb 12 '15 at 13:42
  • sorry i was try .. not array_chunk @prashant :( . i want only key to modification.. sorry my question isn't clear its my fault .. i was edit .. may you know ? – TARA Feb 13 '15 at 08:55
  • i want to make table like this link ... http://home.deib.polimi.it/matteucc/Clustering/tutorial_html/hierarchical.html – TARA Feb 13 '15 at 09:22