PHP函数array_chunk()分割数组

array_chunk() 把一个数组分割成新的数组块

array array_chunk(array $array,int $size[,bool preserve_key])

参数描述:array是分割的数组

size规定每个新数组包含的元素,最后一个数组可能会少几个元素

preserve_key:可选,有两个选项:true,保留原始数组中的键名;false,默认选项,每个结果数组使用从0开始的新数组索引

示例:

$array = array(
    'a'=>'JAVA',
    'b'=>'PHP',
    'c'=>"C++",
    'd'=>'c#',
    'e'=>'perl'
);
print_r(array_chunk($array,2,false));
echo PHP_EOL;
print_r(array_chunk($array,2,true));

运行结果如下:

Array ( [0] => Array ( [0] => JAVA [1] => PHP ) [1] => Array ( [0] => C++ [1] => c# ) [2] => Array ( [0] => perl ) )

Array ( [0] => Array ( [a] => JAVA [b] => PHP ) [1] => Array ( [c] => C++ [d] => c# ) [2] => Array ( [e] => perl ) )
Responses
  1. buy cialis [url=https://calis24.com/#]cialis order online[/url] https://calis24.com/

    Reply
  2. cialis for blood pressure control https://cialisgov.com/ - order cialis how long does it take for cialis to get out of your system?

    Reply
  3. sildenafil citrate 100mg viagra https://sildenafiltools.com/ - sildenafil citrate 100mg sildenafil and ghofrani a and nejm and 2005

    Reply
  4. generic cialis for sale online https://cialisbuffett.com/ - order cialis online take cialis with food

    Reply
  5. desmethyl carbodenafil vs sildenafil https://sildenafilchamp.com/ - sildenafil 50mg difference between 100mg sildenafil

    Reply
  6. buy generic cialis online in usa https://cialisgov.com/ - cialis for sale cost of cialis in uk

    Reply