“array chunk php” Kode Jawaban

array chunk php

$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 ) )
CuteKittyCat

array_chunk dalam 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
                )
            )
mukashwasti_

Jawaban yang mirip dengan “array chunk php”

Pertanyaan yang mirip dengan “array chunk php”

Lebih banyak jawaban terkait untuk “array chunk php” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya