breaking long array in php

Solutions on MaxInterview for breaking long array in php by the best coders in the world

showing results for - "breaking long array in php"
Lebron
09 Aug 2018
1
2To reverse an array_chunk, use array_merge, passing the chunks as a variadic:
3
4<?php
5$array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
6
7$chunks = array_chunk($array, 3);
8// $chunks = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
9
10$de_chunked = array_reduce($array, 'array_merge', []);
11// $de_chunked = [1, 2, 3, 4, 5, 6, 7, 8, 9]
12?>
13
14