3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', true); ini_set('html_errors', false); $cats = array( (object) array("term_id"=>"","name"=>"Film : FIILMTOFTWFUT : post-COLON2","slug" => "alphabetical-k-l-m-n-o ","term_group"=>5,"term_taxonomy_id"=>9,"taxonomy"=>"Myanmar","description"=>"69509","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=> "Country: Cambodia ","slug"=>"Media Relations","term_group"=>5,"term_taxonomy_id"=>7,"taxonomy"=>"Belgium","description"=>"14234","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Advertising","slug"=>"Quality Assurance","term_group"=>5,"term_taxonomy_id"=>1,"taxonomy"=>"Norfolk Island","description"=>"93236","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Finances","slug"=>"Legal Department","term_group"=>5,"term_taxonomy_id"=>5,"taxonomy"=>"Honduras","description"=>"74759","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Legal Department","slug"=>"Media Relations","term_group"=>1,"term_taxonomy_id"=>9,"taxonomy"=>"Namibia","description"=>"69625","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Sales and Marketing","slug"=>"Advertising","term_group"=>2,"term_taxonomy_id"=>4,"taxonomy"=>"Syria","description"=>"56469","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Finances","slug"=>"Media Relations","term_group"=>5,"term_taxonomy_id"=>8,"taxonomy"=>"Ethiopia","description"=>"74909","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Media Relations","slug"=>"Asset Management","term_group"=>5,"term_taxonomy_id"=>9,"taxonomy"=>"Indonesia","description"=>"17623","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Finances","slug"=>"Customer Relations","term_group"=>2,"term_taxonomy_id"=>3,"taxonomy"=>"Zimbabwe","description"=>"83249","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Sales and Marketing","slug" => "alphabetical-k-l-m-n-o ","term_group"=>1,"term_taxonomy_id"=>10,"taxonomy"=>"Faroe Islands","description"=>"03778","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Sales and Marketing","slug"=>"Sales and Marketing","term_group"=>7,"term_taxonomy_id"=>3,"taxonomy"=>"Latvia","description"=>"68525","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Accounting","slug"=>"Research and Development","term_group"=>9,"term_taxonomy_id"=>7,"taxonomy"=>"Bouvet Island","description"=>"18959","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Asset Management","slug"=>"Advertising","term_group"=>1,"term_taxonomy_id"=>9,"taxonomy"=>"Tajikistan","description"=>"94796","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Tech Support : arstatf","slug"=>"Accounting","term_group"=>5,"term_taxonomy_id"=>7,"taxonomy"=>"Côte D'Ivoire (Ivory Coast)","description"=>"24209","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Film : FIILMTOFTWFUT : post-COLON2","slug"=>"Human Resources","term_group"=>9,"term_taxonomy_id"=>3,"taxonomy"=>"Ukraine","description"=>"77647","parent"=>"","count"=>"1"), (object) array("term_id"=>"","name"=>"Media Relations","slug"=>"Customer Service","term_group"=>6,"term_taxonomy_id"=>7,"taxonomy"=>"Maldives","description"=>"97264","parent"=>"","count"=>"1") ); //list($k, $v) = //print_r(explode(' ',$cat->name,2)); //$result[$k]=$v; // $result[] = array_map(function($v){ // return explode(" ", $v); // }, $cat); function getStuff($o) { //$z= get_object_vars($o); //print $o->name; $o = (array)$o; $nameParts = explode(' ',$o['name'],2); list($o['category'], $o['name']) = $nameParts; return $o=(object)$o; ; } $a=array_map('getStuff', $cats); //var_dump($a); $filtered_categories = array(); foreach($a as $element => $value) { $filtered_categories[$value->category][$key] = $value; echo "{$filtered_categories[$value->category][$key]}, {$value}\n"; } ksort($filtered_categories, SORT_REGULAR); //foreach ($filtered_categories as $key => $val) { // echo "$key = $val\n"; //} ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key 1 in /in/qW4h4 on line 47 Warning: Undefined array key 1 in /in/qW4h4 on line 47 Warning: Undefined array key 1 in /in/qW4h4 on line 47 Warning: Undefined array key 1 in /in/qW4h4 on line 47 Warning: Undefined array key 1 in /in/qW4h4 on line 47 Warning: Undefined variable $key in /in/qW4h4 on line 62 Warning: Undefined variable $key in /in/qW4h4 on line 63 Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/qW4h4:63 Stack trace: #0 {main} thrown in /in/qW4h4 on line 63
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/qW4h4:63 Stack trace: #0 {main} thrown in /in/qW4h4 on line 63
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Recoverable fatal error: Object of class stdClass could not be converted to string in /in/qW4h4 on line 63
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Catchable fatal error: Object of class stdClass could not be converted to string in /in/qW4h4 on line 63
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Catchable fatal error: Object of class stdClass could not be converted to string in /in/qW4h4 on line 63
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #17, Object id #17 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #18, Object id #18 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #19, Object id #19 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #20, Object id #20 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #21, Object id #21 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #22, Object id #22 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #23, Object id #23 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #24, Object id #24 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #25, Object id #25 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #26, Object id #26 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #27, Object id #27 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #28, Object id #28 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #29, Object id #29 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #30, Object id #30 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #31, Object id #31 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #32, Object id #32
Output for 5.0.0 - 5.0.3
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #17, Object id #17 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #18, Object id #18 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #19, Object id #19 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #20, Object id #20 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #21, Object id #21 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #22, Object id #22 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #23, Object id #23 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #24, Object id #24 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #25, Object id #25 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #26, Object id #26 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #27, Object id #27 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #28, Object id #28 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #29, Object id #29 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #30, Object id #30 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #31, Object id #31 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object id #32, Object id #32
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined offset: 1 in /in/qW4h4 on line 47 Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object Notice: Undefined variable: key in /in/qW4h4 on line 62 Notice: Undefined variable: key in /in/qW4h4 on line 63 Object, Object

preferences:
334.08 ms | 410 KiB | 459 Q