$indexes=array(0,0);
$bitsandbobs = array();
foreach($categories as $c)
{
$bitsandbobs[$c['smartphoneflag']][$indexes[$c['smartphoneflag']]][]=$c;
if(count($bitsandbobs[$c['smartphoneflag']][$indexes[$c['smartphoneflag']]])==6)
{
$indexes[$c['smartphoneflag']]++;
}
}
$bits = $bitsandbobs[0];
$bobs = $bitsandbobs[1];
$max = count($bobs)>count($bits)?count($bobs):count($bits);
$sorted = array();
for($i=0;$i<$max;$i++)
{
$sorted = array_merge($sorted,$bits[$i]?$bits[$i]:array(),$bobs[$i]?$bobs[$i]:array());
}
You are not logged in, either login or create an account to post comments
Without going into how you ended up needing this:
$bits = array_filter($array,'is_bit');
$bob = array_filter($array,'is_bob');
$total_bits = count($bits);
$total_bobs = count($bobs);
$position = 0;
$output = array();
while($position < $total_bits || $position < $total_bobs)
{
$output += array_slice($bits, $position,6);
$output += array_slice($bobs, $position,6);
$current += 6;
}
function is_bit($item)
{
return $item['type'] == 'bit';
}
function is_bob($item)
{
return $item['type'] == 'bob';
}
posted by Nothing at 8:56 AM on January 24