3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data2 = array( 'category_name' => '33287*100*prescription*1,32457*1250*lab*1' ); // convert simple array to array -> [0]std object $result = array('0' => (object)$data2); foreach ($result as $key => $category) { $category_name = explode(',', $category->category_name); } echo "<pre>";print_r($category_name); $newresults=[]; foreach ($category_name as $key) { $category->category_name = $key; $newresults[]=$category; } $result=$newresults; // replace ids to code in sale data $newresults=[]; $category->items_count = 0; foreach ($result as $key => $value) { list($sale_key, $sale_value) = explode('*', $value->category_name); // $category->items_count += count($sale_value); $newresults[]=$category; } $result=$newresults; echo "<pre>";print_r($result); die();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 48
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 48
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 48
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 27
Branch analysis from position: 14
filename:       /in/CDFpE
function name:  (null)
number of ops:  56
compiled vars:  !0 = $data2, !1 = $result, !2 = $category, !3 = $key, !4 = $category_name, !5 = $newresults, !6 = $value, !7 = $sale_key, !8 = $sale_value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1        CAST                                          8  ~10     !0
          2        INIT_ARRAY                                       ~11     ~10, 0
          3        ASSIGN                                                   !1, ~11
    9     4      > FE_RESET_R                                       $13     !1, ->14
          5    > > FE_FETCH_R                                       ~14     $13, !2, ->14
          6    >   ASSIGN                                                   !3, ~14
   10     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2C'
          9        FETCH_OBJ_R                                      ~16     !2, 'category_name'
         10        SEND_VAL                                                 ~16
         11        DO_ICALL                                         $17     
         12        ASSIGN                                                   !4, $17
    9    13      > JMP                                                      ->5
         14    >   FE_FREE                                                  $13
   13    15        ECHO                                                     '%3Cpre%3E'
         16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                                 
   15    19        ASSIGN                                                   !5, <array>
   16    20      > FE_RESET_R                                       $21     !4, ->27
         21    > > FE_FETCH_R                                               $21, !3, ->27
   17    22    >   ASSIGN_OBJ                                               !2, 'category_name'
         23        OP_DATA                                                  !3
   18    24        ASSIGN_DIM                                               !5
         25        OP_DATA                                                  !2
   16    26      > JMP                                                      ->21
         27    >   FE_FREE                                                  $21
   21    28        ASSIGN                                                   !1, !5
   24    29        ASSIGN                                                   !5, <array>
   26    30        ASSIGN_OBJ                                               !2, 'items_count'
         31        OP_DATA                                                  0
   28    32      > FE_RESET_R                                       $27     !1, ->48
         33    > > FE_FETCH_R                                       ~28     $27, !6, ->48
         34    >   ASSIGN                                                   !3, ~28
   30    35        INIT_FCALL                                               'explode'
         36        SEND_VAL                                                 '%2A'
         37        FETCH_OBJ_R                                      ~30     !6, 'category_name'
         38        SEND_VAL                                                 ~30
         39        DO_ICALL                                         $31     
         40        FETCH_LIST_R                                     $32     $31, 0
         41        ASSIGN                                                   !7, $32
         42        FETCH_LIST_R                                     $34     $31, 1
         43        ASSIGN                                                   !8, $34
         44        FREE                                                     $31
   32    45        ASSIGN_DIM                                               !5
         46        OP_DATA                                                  !2
   28    47      > JMP                                                      ->33
         48    >   FE_FREE                                                  $27
   35    49        ASSIGN                                                   !1, !5
   37    50        ECHO                                                     '%3Cpre%3E'
         51        INIT_FCALL                                               'print_r'
         52        SEND_VAR                                                 !1
         53        DO_ICALL                                                 
   38    54      > EXIT                                                     
         55*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.27 ms | 1011 KiB | 15 Q