3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), array('subcategory_id'=>1, 'subcategory'=>'cheeseburgers'), ); $col_height = 10; // set column to 10 items tall $count = count($array); $row_len = $count / $col_height; $i = 0; foreach($array as $row) { $i++; echo $row['subcategory']; echo ($col_height % $count == 0) ? "\n" : "\t"; }
based on rDCPf
Output for 5.3.17 - 7.2.0
cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers cheeseburgers