3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dbjunk = "Itemid:Quantity:Price:name, itemid2:quantity2:price2:name2"; $parsed = parseItems($dbjunk); print_r($parsed); function parseItems($dbjunk){ $cart = array(); $items = explode(",",$dbjunk); foreach($items as $i){ $chunks = explode(":", $i); $cart[] = array( "ItemID" => $chunks[0] , "Quantity" => $chunks[1] , "Price" => $chunks[2] , "name" => $chunks[3] ); } return $cart; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBkXF
function name:  (null)
number of ops:  9
compiled vars:  !0 = $dbjunk, !1 = $parsed
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   QM_ASSIGN                                                !0
   4     1        INIT_FCALL_BY_NAME                                       'parseItems'
         2        SEND_VAR_EX                                              !0
         3        DO_FCALL                                      0  $3      
         4        QM_ASSIGN                                                !1
   5     5        INIT_FCALL                                               'print_r'
         6        SEND_VAR                                                 !1
         7        DO_ICALL                                                 
  20     8      > RETURN                                                   1

Function parseitems:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 25
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/rBkXF
function name:  parseItems
number of ops:  28
compiled vars:  !0 = $dbjunk, !1 = $cart, !2 = $items, !3 = $i, !4 = $chunks
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   RECV                                             !0      
   8     1        QM_ASSIGN                                                !1
   9     2        INIT_FCALL                                               'explode'
         3        SEND_VAL                                                 '%2C'
         4        SEND_VAR                                                 !0
         5        DO_ICALL                                         $6      
         6        QM_ASSIGN                                                !2
  10     7      > FE_RESET_R                                       $8      !2, ->25
         8    > > FE_FETCH_R                                               $8, !3, ->25
  11     9    >   INIT_FCALL                                               'explode'
        10        SEND_VAL                                                 '%3A'
        11        SEND_VAR                                                 !3
        12        DO_ICALL                                         $9      
        13        QM_ASSIGN                                                !4
  13    14        FETCH_DIM_R                                      ~12     !4, 0
        15        INIT_ARRAY                                       ~13     ~12, 'ItemID'
  14    16        FETCH_DIM_R                                      ~14     !4, 1
        17        ADD_ARRAY_ELEMENT                                ~13     ~14, 'Quantity'
  15    18        FETCH_DIM_R                                      ~15     !4, 2
        19        ADD_ARRAY_ELEMENT                                ~13     ~15, 'Price'
  16    20        FETCH_DIM_R                                      ~16     !4, 3
        21        ADD_ARRAY_ELEMENT                                ~13     ~16, 'name'
  12    22        ASSIGN_ADD                                    0          !1
  16    23        OP_DATA                                                  ~13
  10    24      > JMP                                                      ->8
        25    >   FE_FREE                                                  $8
  19    26      > RETURN                                                   !1
  20    27*     > RETURN                                                   null

End of function parseitems

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
12.77 ms | 467 KiB | 7 Q