I am having a data in array format with key and value what i want is from first key 0 to key 6 data i want to store in new array with index 0 same for every other key 7 to 13 key with 1 index in new array in php
CodePudding user response:
First, as suggested above, do not upload image of your code, just paste it here.
Just use PHP array_chunk function:
$pieces = array_chunk($my_array, 6);
CodePudding user response:
you can use array_chunk()
function
<?php
$a = ["a","a","a","a","a","a","a","a"];
$b = array_chunk($a, 7);
echo"<pre>";print_r($b);
?>
output be like:
Array
(
[0] => Array
(
[0] => a
[1] => a
[2] => a
[3] => a
[4] => a
[5] => a
[6] => a
)
[1] => Array
(
[0] => a
)
)