3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $example1 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "111111", "ExpDate" => "2013-07-31", "Level" => "WELITE", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example2 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "222222", "ExpDate" => "2013-07-31", "Level" => "WELITE", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example3 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "22222", "ExpDate" => "2013-07-31", "Level" => "DEMO", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example4 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "22222", "ExpDate" => "2013-07-31", "Level" => "DEMO", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); // Initial array $initArray = array($example1, $example2, $example3, $example4); $finalArray = array(); $i = 0; foreach ($initArray as $key => $value) { (isset($value['Level'])) ? $finalArray[$value['Level']][$i] = $value : NULL; unset($finalArray[$value['Level']][$i]['Level']); // Add this line to fix indexes sort($finalArray[$value['Level']]); $i++; } echo '<pre>', print_r($finalArray, true), '</pre>'; //echo '<pre>', print_r($second, true), '</pre>';
Output for 4.3.0 - 5.0.5, 5.1.1 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
<pre>Array ( [WELITE] => Array ( [0] => Array ( [OrgID] => XXXX [DOB] => 1970-01-01 [PersonID] => 111111 [ExpDate] => 2013-07-31 [Status] => Active [FName] => Jane [LName] => Doe [Checked] => ) [1] => Array ( [OrgID] => XXXX [DOB] => 1970-01-01 [PersonID] => 222222 [ExpDate] => 2013-07-31 [Status] => Active [FName] => Jane [LName] => Doe [Checked] => ) ) [DEMO] => Array ( [0] => Array ( [OrgID] => XXXX [DOB] => 1970-01-01 [PersonID] => 22222 [ExpDate] => 2013-07-31 [Status] => Active [FName] => Jane [LName] => Doe [Checked] => ) [1] => Array ( [OrgID] => XXXX [DOB] => 1970-01-01 [PersonID] => 22222 [ExpDate] => 2013-07-31 [Status] => Active [FName] => Jane [LName] => Doe [Checked] => ) ) ) </pre>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/N2eCd on line 64
Process exited with code 255.