3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dbjunk = "Itemid:Quantity:Price:name, itemid2:quantity2:price2:name2"; $parsed = parseItems($dbjunk); foreach($parsed as $p){ list($itemID, $Quantity, $Price, $name) = array_values($p); var_dump($itemID, $Quantity, $Price, $name); } 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
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 26
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/l4vsn
function name:  (null)
number of ops:  28
compiled vars:  !0 = $dbjunk, !1 = $parsed, !2 = $p, !3 = $itemID, !4 = $Quantity, !5 = $Price, !6 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Itemid%3AQuantity%3APrice%3Aname%2C+itemid2%3Aquantity2%3Aprice2%3Aname2'
    4     1        INIT_FCALL_BY_NAME                                       'parseItems'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $8      
          4        ASSIGN                                                   !1, $8
    5     5      > FE_RESET_R                                       $10     !1, ->26
          6    > > FE_FETCH_R                                               $10, !2, ->26
    6     7    >   INIT_FCALL                                               'array_values'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $11     
         10        FETCH_LIST_R                                     $12     $11, 0
         11        ASSIGN                                                   !3, $12
         12        FETCH_LIST_R                                     $14     $11, 1
         13        ASSIGN                                                   !4, $14
         14        FETCH_LIST_R                                     $16     $11, 2
         15        ASSIGN                                                   !5, $16
         16        FETCH_LIST_R                                     $18     $11, 3
         17        ASSIGN                                                   !6, $18
         18        FREE                                                     $11
    7    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !3
         21        SEND_VAR                                                 !4
         22        SEND_VAR                                                 !5
         23        SEND_VAR                                                 !6
         24        DO_ICALL                                                 
    5    25      > JMP                                                      ->6
         26    >   FE_FREE                                                  $10
   23    27      > 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/l4vsn
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
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, <array>
   12     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   13     7      > FE_RESET_R                                       $8      !2, ->25
          8    > > FE_FETCH_R                                               $8, !3, ->25
   14     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%3A'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !4, $9
   16    14        FETCH_DIM_R                                      ~12     !4, 0
         15        INIT_ARRAY                                       ~13     ~12, 'ItemID'
   17    16        FETCH_DIM_R                                      ~14     !4, 1
         17        ADD_ARRAY_ELEMENT                                ~13     ~14, 'Quantity'
   18    18        FETCH_DIM_R                                      ~15     !4, 2
         19        ADD_ARRAY_ELEMENT                                ~13     ~15, 'Price'
   19    20        FETCH_DIM_R                                      ~16     !4, 3
         21        ADD_ARRAY_ELEMENT                                ~13     ~16, 'name'
   15    22        ASSIGN_DIM                                               !1
   19    23        OP_DATA                                                  ~13
   13    24      > JMP                                                      ->8
         25    >   FE_FREE                                                  $8
   22    26      > RETURN                                                   !1
   23    27*     > RETURN                                                   null

End of function parseitems

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.46 ms | 1400 KiB | 19 Q