Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

breaking long array in php


To reverse an array_chunk, use array_merge, passing the chunks as a variadic:

<?php
$array = [1, 2, 3, 4, 5, 6, 7, 8, 9];

$chunks = array_chunk($array, 3);
// $chunks = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

$de_chunked = array_reduce($array, 'array_merge', []);
// $de_chunked = [1, 2, 3, 4, 5, 6, 7, 8, 9]
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #breaking #long #array #php
ADD COMMENT
Topic
Name
3+5 =