3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = Array ( 'items' => Array ( '0' => Array ( 'sku' => 'SCB20', 'custom_attributes' => Array ( '0' => Array ( 'attribute_code' => 'ages', 'value' => 17 ), '1' => Array ( 'attribute_code' => 'description', 'value' => 'description data' ), '2' => Array ( 'attribute_code' => 'image', 'value' => 'cl2eojpu9.jpg' ) ) ) ) ); $searchCode = 'ages'; $attributeValue = ''; $flag = false; array_walk_recursive($a, function($item, $key, &$flag) use ($searchCode,&$attributeValue){ if($key == 'attribute_code' && $item == $searchCode){ $flag = true; } if($flag){ $attributeValue = $item; } }, $flag); echo $attributeValue;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/erlZD
function name:  (null)
number of ops:  14
compiled vars:  !0 = $a, !1 = $searchCode, !2 = $attributeValue, !3 = $flag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        ASSIGN                                                   !1, 'ages'
   34     2        ASSIGN                                                   !2, ''
   35     3        ASSIGN                                                   !3, <false>
   36     4        INIT_FCALL                                               'array_walk_recursive'
          5        SEND_REF                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FerlZD%3A36%240'
          7        BIND_LEXICAL                                             ~8, !1
          8        BIND_LEXICAL                                             ~8, !2
   43     9        SEND_VAL                                                 ~8
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
   44    12        ECHO                                                     !2
   45    13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FerlZD%3A36%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 11
Branch analysis from position: 9
filename:       /in/erlZD
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $item, !1 = $key, !2 = $flag, !3 = $searchCode, !4 = $attributeValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        BIND_STATIC                                              !3
          4        BIND_STATIC                                              !4
   37     5        IS_EQUAL                                         ~5      !1, 'attribute_code'
          6      > JMPZ_EX                                          ~5      ~5, ->9
          7    >   IS_EQUAL                                         ~6      !0, !3
          8        BOOL                                             ~5      ~6
          9    > > JMPZ                                                     ~5, ->11
   38    10    >   ASSIGN                                                   !2, <true>
   40    11    > > JMPZ                                                     !2, ->13
   41    12    >   ASSIGN                                                   !4, !0
   43    13    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FerlZD%3A36%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.31 ms | 1396 KiB | 15 Q