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"; //} ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 66
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 66
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
filename:       /in/qW4h4
function name:  (null)
number of ops:  72
compiled vars:  !0 = $cats, !1 = $a, !2 = $filtered_categories, !3 = $value, !4 = $element, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    5     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                                 
    6     7        INIT_FCALL                                               'ini_set'
          8        SEND_VAL                                                 'html_errors'
          9        SEND_VAL                                                 <false>
         10        DO_ICALL                                                 
   10    11        CAST                                          8  ~9      <array>
         12        INIT_ARRAY                                       ~10     ~9
   11    13        CAST                                          8  ~11     <array>
         14        ADD_ARRAY_ELEMENT                                ~10     ~11
   12    15        CAST                                          8  ~12     <array>
         16        ADD_ARRAY_ELEMENT                                ~10     ~12
   13    17        CAST                                          8  ~13     <array>
         18        ADD_ARRAY_ELEMENT                                ~10     ~13
   14    19        CAST                                          8  ~14     <array>
         20        ADD_ARRAY_ELEMENT                                ~10     ~14
   15    21        CAST                                          8  ~15     <array>
         22        ADD_ARRAY_ELEMENT                                ~10     ~15
   16    23        CAST                                          8  ~16     <array>
         24        ADD_ARRAY_ELEMENT                                ~10     ~16
   17    25        CAST                                          8  ~17     <array>
         26        ADD_ARRAY_ELEMENT                                ~10     ~17
   18    27        CAST                                          8  ~18     <array>
         28        ADD_ARRAY_ELEMENT                                ~10     ~18
   19    29        CAST                                          8  ~19     <array>
         30        ADD_ARRAY_ELEMENT                                ~10     ~19
   20    31        CAST                                          8  ~20     <array>
         32        ADD_ARRAY_ELEMENT                                ~10     ~20
   21    33        CAST                                          8  ~21     <array>
         34        ADD_ARRAY_ELEMENT                                ~10     ~21
   22    35        CAST                                          8  ~22     <array>
         36        ADD_ARRAY_ELEMENT                                ~10     ~22
   23    37        CAST                                          8  ~23     <array>
         38        ADD_ARRAY_ELEMENT                                ~10     ~23
   24    39        CAST                                          8  ~24     <array>
         40        ADD_ARRAY_ELEMENT                                ~10     ~24
   25    41        CAST                                          8  ~25     <array>
         42        ADD_ARRAY_ELEMENT                                ~10     ~25
    8    43        ASSIGN                                                   !0, ~10
   56    44        INIT_FCALL                                               'array_map'
         45        SEND_VAL                                                 'getStuff'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                         $27     
         48        ASSIGN                                                   !1, $27
   59    49        ASSIGN                                                   !2, <array>
   60    50      > FE_RESET_R                                       $30     !1, ->66
         51    > > FE_FETCH_R                                       ~31     $30, !3, ->66
         52    >   ASSIGN                                                   !4, ~31
   62    53        FETCH_OBJ_R                                      ~33     !3, 'category'
         54        FETCH_DIM_W                                      $34     !2, ~33
         55        ASSIGN_DIM                                               $34, !5
         56        OP_DATA                                                  !3
   63    57        FETCH_OBJ_R                                      ~36     !3, 'category'
         58        FETCH_DIM_R                                      ~37     !2, ~36
         59        FETCH_DIM_R                                      ~38     ~37, !5
         60        ROPE_INIT                                     4  ~40     ~38
         61        ROPE_ADD                                      1  ~40     ~40, '%2C+'
         62        ROPE_ADD                                      2  ~40     ~40, !3
         63        ROPE_END                                      3  ~39     ~40, '%0A'
         64        ECHO                                                     ~39
   60    65      > JMP                                                      ->51
         66    >   FE_FREE                                                  $30
   65    67        INIT_FCALL                                               'ksort'
         68        SEND_REF                                                 !2
         69        SEND_VAL                                                 0
         70        DO_ICALL                                                 
   70    71      > RETURN                                                   1

Function getstuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qW4h4
function name:  getStuff
number of ops:  22
compiled vars:  !0 = $o, !1 = $nameParts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   45     1        CAST                                          7  ~2      !0
          2        ASSIGN                                                   !0, ~2
   46     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '+'
          5        FETCH_DIM_R                                      ~4      !0, 'name'
          6        SEND_VAL                                                 ~4
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   47    10        QM_ASSIGN                                        ~7      !1
         11        FETCH_LIST_R                                     $8      ~7, 0
         12        ASSIGN_DIM                                               !0, 'category'
         13        OP_DATA                                                  $8
         14        FETCH_LIST_R                                     $10     ~7, 1
         15        ASSIGN_DIM                                               !0, 'name'
         16        OP_DATA                                                  $10
         17        FREE                                                     ~7
   50    18        CAST                                          8  ~12     !0
         19        ASSIGN                                           ~13     !0, ~12
         20      > RETURN                                                   ~13
   54    21*     > RETURN                                                   null

End of function getstuff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.84 ms | 1404 KiB | 23 Q