3v4l.org

run code in 300+ PHP versions simultaneously
<?php $results = array ( array( 'body' => 'somevalue1', 'title' => 'somevalue1', 'type' => 'foo' ), array( 'body' => 'somevalue2', 'title' => 'somevalue2', 'type' => 'foo' ), array( 'body' => 'somevalue3', 'title' => 'somevalue3', 'type' => 'bar' ), array( 'body' => 'somevalue4', 'title' => 'somevalue4', 'type' => 'foobar' ), array( 'body' => 'somevalue5', 'title' => 'somevalue5', 'type' => 'foobar' ), array( 'body' => 'somevalue6', 'title' => 'somevalue6', 'type' => 'foobar' ), ); foreach($results as $a){ $output[$a['type']][]=array_slice($a,0,2); } var_export($output);

preferences:
51.6 ms | 402 KiB | 5 Q