Split an array into chunks of two and preserve the original keys:


SUBMITTED BY: henry1874w

DATE: June 22, 2017, 12:08 a.m.

FORMAT: Text only

SIZE: 115 Bytes

HITS: 326

  1. <?php
  2. $age=array
  3. ("Peter"=>"35","Ben"=>"37","Joe"=>"43","Harry
  4. "=>"50");
  5. print_r(array_chunk($age,2,true));
  6. ?>

comments powered by Disqus