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; list($o['name']) = explode(' ',$o['name'],2); // print "{$o['name']} \n"; return $o=(object)$o; // print "{$o->name} \n"; //print $o=>name; //return $z; // explode(' ',$o->name,2)[0]//]= explode('',$o->name,2)[1]; // $o = (object) array_merge( (array)$o, array( explode(' ',$o->name,2)[0] => '1234' ) ); ; } $a=array_map('getStuff', $cats); print_r($a) /* $newArr = array(); foreach($cats as $cat){ $newArr[$cat->name][] = (array)$cat; } var_dump($newArr);*/ ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iKB7A
function name:  (null)
number of ops:  53
compiled vars:  !0 = $cats, !1 = $a
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  ~5      <array>
         12        INIT_ARRAY                                       ~6      ~5
   11    13        CAST                                          8  ~7      <array>
         14        ADD_ARRAY_ELEMENT                                ~6      ~7
   12    15        CAST                                          8  ~8      <array>
         16        ADD_ARRAY_ELEMENT                                ~6      ~8
   13    17        CAST                                          8  ~9      <array>
         18        ADD_ARRAY_ELEMENT                                ~6      ~9
   14    19        CAST                                          8  ~10     <array>
         20        ADD_ARRAY_ELEMENT                                ~6      ~10
   15    21        CAST                                          8  ~11     <array>
         22        ADD_ARRAY_ELEMENT                                ~6      ~11
   16    23        CAST                                          8  ~12     <array>
         24        ADD_ARRAY_ELEMENT                                ~6      ~12
   17    25        CAST                                          8  ~13     <array>
         26        ADD_ARRAY_ELEMENT                                ~6      ~13
   18    27        CAST                                          8  ~14     <array>
         28        ADD_ARRAY_ELEMENT                                ~6      ~14
   19    29        CAST                                          8  ~15     <array>
         30        ADD_ARRAY_ELEMENT                                ~6      ~15
   20    31        CAST                                          8  ~16     <array>
         32        ADD_ARRAY_ELEMENT                                ~6      ~16
   21    33        CAST                                          8  ~17     <array>
         34        ADD_ARRAY_ELEMENT                                ~6      ~17
   22    35        CAST                                          8  ~18     <array>
         36        ADD_ARRAY_ELEMENT                                ~6      ~18
   23    37        CAST                                          8  ~19     <array>
         38        ADD_ARRAY_ELEMENT                                ~6      ~19
   24    39        CAST                                          8  ~20     <array>
         40        ADD_ARRAY_ELEMENT                                ~6      ~20
   25    41        CAST                                          8  ~21     <array>
         42        ADD_ARRAY_ELEMENT                                ~6      ~21
    8    43        ASSIGN                                                   !0, ~6
   57    44        INIT_FCALL                                               'array_map'
         45        SEND_VAL                                                 'getStuff'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                         $23     
         48        ASSIGN                                                   !1, $23
   58    49        INIT_FCALL                                               'print_r'
         50        SEND_VAR                                                 !1
         51        DO_ICALL                                                 
   68    52      > RETURN                                                   1

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

End of function getstuff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.7 ms | 1400 KiB | 23 Q