3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ (object) ['graduateYear' => 'Class of 2007', 'id' => 1, 'lastsName' => 'Igbashio', 'firstName' => 'Kalifort'], (object) ['graduateYear' => 'Class of 2007', 'id' => 2, 'lastsName' => 'Usman', 'firstName' => 'Bello'], (object) ['graduateYear' => 'Class of 2007', 'id' => 3, 'lastsName' => 'Manasseh', 'firstName' => 'Isa'], (object) ['graduateYear' => 'Class of 2008', 'id' => 4, 'lastsName' => 'Igbashio', 'firstName' => 'Sansa'], (object) ['graduateYear' => 'Class of 2008', 'id' => 5, 'lastsName' => 'Yusuf', 'firstName' => "Sa'atu"], (object) ['graduateYear' => 'Class of 2008', 'id' => 6, 'lastsName' => 'Rimamtse', 'firstName' => 'Bleesing'], ]; $grouped = []; foreach ($array as $obj) { sscanf($obj->graduateYear, 'Class of %d', $year); unset($obj->graduateYear); $grouped[$year]['title'] = $year; // doesn't matter that this is overwritten over and over $grouped[$year]['data'][] = $obj; } var_export(array_values($grouped));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'title' => 2007, 'data' => array ( 0 => (object) array( 'id' => 1, 'lastsName' => 'Igbashio', 'firstName' => 'Kalifort', ), 1 => (object) array( 'id' => 2, 'lastsName' => 'Usman', 'firstName' => 'Bello', ), 2 => (object) array( 'id' => 3, 'lastsName' => 'Manasseh', 'firstName' => 'Isa', ), ), ), 1 => array ( 'title' => 2008, 'data' => array ( 0 => (object) array( 'id' => 4, 'lastsName' => 'Igbashio', 'firstName' => 'Sansa', ), 1 => (object) array( 'id' => 5, 'lastsName' => 'Yusuf', 'firstName' => 'Sa\'atu', ), 2 => (object) array( 'id' => 6, 'lastsName' => 'Rimamtse', 'firstName' => 'Bleesing', ), ), ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
19.78 ms | 408 KiB | 5 Q