3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getParts() { return json_decode(<<<EOF [ { "name": "lorem ipsum", "category": "hi", "quantity": "2", "price": "55", "id": 1756378, "shelf": "30", "slot": "173" }, { "name": "foo bar", "category": "there", "quantity": "2", "price": "90", "id": 1181335, "shelf": "", "slot": "" } ] EOF , true); } function getPartByName($name) { $matches = []; $parts = getParts(); foreach ($parts as $part) { if (str_starts_with($part['name'], $name)) { $matches[] = $part; } } return $matches; } print_r(getPartByName('lorem'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dK21a
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                                   'print_r'
          1        INIT_FCALL                                                   'getpartbyname'
          2        SEND_VAL                                                     'lorem'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
          6      > RETURN                                                       1

Function getparts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dK21a
function name:  getParts
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                                   'json_decode'
    6     1        SEND_VAL                                                     '%5B%0A++++%7B%0A++++++++%22name%22%3A+%22lorem+ipsum%22%2C%0A++++++++%22category%22%3A+%22hi%22%2C%0A++++++++%22quantity%22%3A+%222%22%2C%0A++++++++%22price%22%3A+%2255%22%2C%0A++++++++%22id%22%3A+1756378%2C%0A++++++++%22shelf%22%3A+%2230%22%2C%0A++++++++%22slot%22%3A+%22173%22%0A++++%7D%2C%0A++++%7B%0A++++++++%22name%22%3A+%22foo+bar%22%2C%0A++++++++%22category%22%3A+%22there%22%2C%0A++++++++%22quantity%22%3A+%222%22%2C%0A++++++++%22price%22%3A+%2290%22%2C%0A++++++++%22id%22%3A+1181335%2C%0A++++++++%22shelf%22%3A+%22%22%2C%0A++++++++%22slot%22%3A+%22%22%0A++++%7D%0A%5D'
   27     2        SEND_VAL                                                     <true>
    5     3        DO_ICALL                                             $0      
   27     4      > RETURN                                                       $0
   28     5*     > RETURN                                                       null

End of function getparts

Function getpartbyname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/dK21a
function name:  getPartByName
number of ops:  16
compiled vars:  !0 = $name, !1 = $matches, !2 = $parts, !3 = $part
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
   32     1        ASSIGN                                                       !1, <array>
   34     2        INIT_FCALL                                                   'getparts'
          3        DO_FCALL                                          0  $5      
          4        ASSIGN                                                       !2, $5
   35     5      > FE_RESET_R                                           $7      !2, ->13
          6    > > FE_FETCH_R                                                   $7, !3, ->13
   36     7    >   FETCH_DIM_R                                          ~8      !3, 'name'
          8        FRAMELESS_ICALL_2                str_starts_with      ~9      ~8, !0
          9      > JMPZ                                                         ~9, ->12
   37    10    >   ASSIGN_DIM                                                   !1
         11        OP_DATA                                                      !3
   35    12    > > JMP                                                          ->6
         13    >   FE_FREE                                                      $7
   41    14      > RETURN                                                       !1
   42    15*     > RETURN                                                       null

End of function getpartbyname

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
115.96 ms | 495 KiB | 13 Q