[pmwiki-devel] array transform question

Hans design5 at softflow.co.uk
Fri Apr 13 01:52:05 CDT 2007


Thursday, April 12, 2007, 9:11:02 PM, Hans wrote:

> $p = array($p[0],$p[1],$p2],$p[3],$p[4],.....,$p[$n]);
> $ppp = 3; (for instance)
> $n = 7 for instance
> $new = array($p[0], $p[1].$p[2].$p[3], $p[4].$p[5].$p[6], $p[7]);

> so the new array combines groups of elements, starting with $p[1], in
> groups of $ppp elements.

I found this solution:

   $new = array_splice($p, 0, 1);
   while(count($p)>0) {
      $sp = array_splice($p, 0, $ppp);
      $new[] = implode('', $sp);
   }


Hans




More information about the pmwiki-devel mailing list