3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"2":[ {"title":"english title","link":"english url"}, {"title":"","link":""}], "1":[ {"title":"french title","link":"french url"}, {"title":"","link":""}]}'; $links = json_decode($json, true); array_walk($links, function (&$array) { $array = array_filter($array, function ($obj) { return $obj['title'] != '' || $obj['link'] != ''; }); }); print_r($links);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/catFY
function name:  (null)
number of ops:  15
compiled vars:  !0 = $json, !1 = $links
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%222%22%3A%5B%0A%7B%22title%22%3A%22english+title%22%2C%22link%22%3A%22english+url%22%7D%2C%0A%7B%22title%22%3A%22%22%2C%22link%22%3A%22%22%7D%5D%2C%0A%221%22%3A%5B%0A%7B%22title%22%3A%22french+title%22%2C%22link%22%3A%22french+url%22%7D%2C%0A%7B%22title%22%3A%22%22%2C%22link%22%3A%22%22%7D%5D%7D'
    9     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   11     6        INIT_FCALL                                               'array_walk'
          7        SEND_REF                                                 !1
          8        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   15     9        SEND_VAL                                                 ~5
   11    10        DO_ICALL                                                 
   17    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/catFY
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   14     4        SEND_VAL                                                 ~1
   12     5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   15     7      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/catFY
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_DIM_R                                      ~1      !0, 'title'
          2        IS_NOT_EQUAL                                     ~2      ~1, ''
          3      > JMPNZ_EX                                         ~2      ~2, ->7
          4    >   FETCH_DIM_R                                      ~3      !0, 'link'
          5        IS_NOT_EQUAL                                     ~4      ~3, ''
          6        BOOL                                             ~2      ~4
          7    > > RETURN                                                   ~2
   14     8*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.54 ms | 1006 KiB | 17 Q