php basic operations question -


i have array of 50 elements. array can of size anything. want have first 10 elements of array in string.

i have program as:

$array1= array("itself", "aith","inside","engineer","cooool","that","it","because");  $i=0; for($f=0; $f < sizeof(array1); $f++) {     $temparry = $temparry.array1[$f];      if(($f%10) == 0 && ($f !== 0))     {          $temparray[$i] = $temparray;          $i++;        } } 

== @ end:
get
temparray1= first 10 elements
temparray2 - next 10 elemnts...

i not missing in loops.

after reading comment, think want array_chunk [docs]:

$chunks = array_chunk($array1, 10); 

this create multidimensional array each element being array containing 10 elements.

if still want join them string, can use array_map [docs] , implode [docs]:

$strings = array_map('implode', $chunks); 

this gives array of strings, each element concatenation of chunk.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -