I want to divide array into specific chunks
Like
array1 = 24%;
开发者_JS百科 array2 = 50%;
array3 = 26%;
$myArray = array("abc","def","ghi","jkl","mno","pqr","stu","vwx","yz");
$newArray = array_chunk($myArray, 3, false);
Array may contain billions of records.
$cnt=count($myArray);
$cnt1=round($cnt*0.24);
$cnt2=round($cnt*0.5);
//use array_slice $here
array(
array_slice($array,0,$cnt1);
array_slice($array,$cnt1,$cnt2);
array_slice($array,$cnt1+$cnt2);
);
Try looking into array_slice()
.
精彩评论