3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '[ { "type": "youtube" }, { "type": "Picture" }, { "type": "Gallery" } ]'; $arr = json_decode($str, true); $type = array_column($arr, 'type'); $key = array_search('youtube', $type); if($key === false){ $key = array_search('Picture', $type); } Var_dump($key);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Cbs1u
function name:  (null)
number of ops:  27
compiled vars:  !0 = $str, !1 = $arr, !2 = $type, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A++++%7B%0A+++++%22type%22%3A+%22youtube%22%0A++++%7D%2C%0A++++%7B%0A+++++%22type%22%3A+%22Picture%22%0A++++%7D%2C%0A++++%7B%0A+++++%22type%22%3A+%22Gallery%22%0A++++%7D%0A%5D'
   15     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   17     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 'type'
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
   18    11        INIT_FCALL                                               'array_search'
         12        SEND_VAL                                                 'youtube'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !3, $9
   20    16        TYPE_CHECK                                    4          !3
         17      > JMPZ                                                     ~11, ->23
   21    18    >   INIT_FCALL                                               'array_search'
         19        SEND_VAL                                                 'Picture'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !3, $12
   25    23    >   INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.2 ms | 1005 KiB | 17 Q