Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php chunk array

$array=['a','b','c','d','e','f','g'];
$chunckedArray=array_chunk($array,3);
//output: $chunkedArray=[['a','b','c'],['d','e','f'],['g']]
//Array ( [0] => Array ( [0] => a [1] => b [2] => c ) [1] => Array ( [0] => d [1] => e [2] => f ) [2] => Array ( [0] => g ) )
Comment

array_chunk in php

Input : $input_array = array('a', 'b', 'c', 'd', 'e');
        array_chunk($input_array, 2);
Output : Array(
                [0] => Array
                (
                    [0] => a
                    [1] => b
                )
                [1] => Array
                (
                    [0] => c
                    [1] => d
                )
                [2] => Array
                (
                    [0] => e
                )
            )

Input : $input_array = array('a', 'b', 'c', 'd', 'e');
       array_chunk($input_array, 2, true)
Output :    Array
            (
                [0] => Array
                (
                    [0] => a
                    [1] => b
                )
                [1] => Array
                (
                    [2] => c
                    [3] => d
                )
                [2] => Array
                (
                    [4] => e
                )
            )
Comment

PREVIOUS NEXT
Code Example
Php :: php remove 1 day from date 
Php :: php repeat string 
Php :: implode php 
Php :: Fatal error: Uncaught ReflectionException: Class config does not exist in 
Php :: php check if url parameter exists 
Php :: carbon finer 
Php :: acf get user form field 
Php :: php count array elements with specific key 
Php :: how to install dompdf in laravel 
Php :: laravel where condition on relationship 
Php :: php remove object from array by property 
Php :: how to create a get route in Laravel 
Php :: guzzle post request with data 
Php :: laravel create model with migration 
Php :: display all custom post type ids 
Php :: wordpress global variable not working 
Php :: laravel validation max string length 
Php :: how to check if PHP-FPM is running 
Php :: migration with seeder laravel 
Php :: php get array key by value multidimensional 
Php :: how to get the average in sql in php 
Php :: laravel date default now 
Php :: wordpress get post slug 
Php :: php get and print file contents 
Php :: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes) 
Php :: php all date formats 
Php :: disable cors policy symfony 
Php :: phpmyadmin first login 
Php :: php count amount of times a value appears in array 
Php :: php delete element from array 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =