PHP Programing language

R4R® PHP
array_chunk() Function in PHP
(追記) (追記ここまで)
(追記) (追記ここまで)

array_chunk()

The array_chunk() function splits an array into chunks of new arrays.

Syntax:
array_chunk(array,size,preserve_key);

In above syntax, "array" specifies the array to use, "size" is an integer that specifies the size of each chunk and "preserve_key" preserve_key values are as follows:

  • true: Preserves the keys
  • false: Default and reindexes the chunk numerically
(追記) (追記ここまで)

Example:

<?php
$fruit_weight=array("Apple"=>"5kg","Banana"=>"7kg","Mango"=>"10kg");
print_r(array_chunk($fruit_weight,2));
?>

Output:

Array ( [0] => Array ( [0] => 5kg [1] => 7kg ) [1] => Array ( [0] => 10kg ) )

(追記) (追記ここまで)
Copyright ©2021-22 r4r.co.in, all rights reserved. Theguestspost.com
Sitemap
Career
Post comment
About us
Subscription
Unsubscription

AltStyle によって変換されたページ (->オリジナル) /