3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = <<<JSON { "total":2000, "achievements":[ { "id":6, "achievement":{}, "criteria":{ "id":2050, "is_completed":false }, "completed_timestamp":1224053510000 }, { "id":8, "achievement":{}, "criteria":{ "id":1289, "is_completed":true }, "completed_timestamp":1224053510000 } ] } JSON; try { $data = json_decode($json, false, 512, JSON_THROW_ON_ERROR); $completedAchievements = array_filter( $data->achievements, static function (\stdClass $achievement): bool { return $achievement->criteria->is_completed === true; } ); $completedAchievementsIds = array_column($completedAchievements, 'id'); print_r($completedAchievementsIds); } catch (JsonException $e) { echo $e->getMessage(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 24
Branch analysis from position: 24
2 jumps found. (Code = 107) Position 1 = 25, Position 2 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6futr
function name:  (null)
number of ops:  29
compiled vars:  !0 = $json, !1 = $data, !2 = $completedAchievements, !3 = $completedAchievementsIds, !4 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B+++%0A++%22total%22%3A2000%2C%0A++%22achievements%22%3A%5B%0A++++%7B%0A+++++++%22id%22%3A6%2C%0A+++++++%22achievement%22%3A%7B%7D%2C%0A+++++++%22criteria%22%3A%7B%0A++++++++++%22id%22%3A2050%2C%0A++++++++++%22is_completed%22%3Afalse%0A+++++++%7D%2C%0A+++++++%22completed_timestamp%22%3A1224053510000%0A++++%7D%2C%0A++++%7B%0A+++++++%22id%22%3A8%2C%0A+++++++%22achievement%22%3A%7B%7D%2C%0A+++++++%22criteria%22%3A%7B%0A++++++++++%22id%22%3A1289%2C%0A++++++++++%22is_completed%22%3Atrue%0A+++++++%7D%2C%0A+++++++%22completed_timestamp%22%3A1224053510000%0A++++%7D%0A++%5D%0A%7D'
   30     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <false>
          4        SEND_VAL                                                     512
          5        SEND_VAL                                                     4194304
          6        DO_ICALL                                             $6      
          7        ASSIGN                                                       !1, $6
   31     8        INIT_FCALL                                                   'array_filter'
   32     9        FETCH_OBJ_R                                          ~8      !1, 'achievements'
         10        SEND_VAL                                                     ~8
   33    11        DECLARE_LAMBDA_FUNCTION                              ~9      [0]
   35    12        SEND_VAL                                                     ~9
   31    13        DO_ICALL                                             $10     
         14        ASSIGN                                                       !2, $10
   37    15        INIT_FCALL                                                   'array_column'
         16        SEND_VAR                                                     !2
         17        SEND_VAL                                                     'id'
         18        DO_ICALL                                             $12     
         19        ASSIGN                                                       !3, $12
   38    20        INIT_FCALL                                                   'print_r'
         21        SEND_VAR                                                     !3
         22        DO_ICALL                                                     
         23      > JMP                                                          ->28
   40    24  E > > CATCH                                           last         'JsonException'
   41    25    >   INIT_METHOD_CALL                                             !4, 'getMessage'
         26        DO_FCALL                                          0  $15     
         27        ECHO                                                         $15
   42    28    > > 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/6futr
function name:  {closure:/in/6futr:33}
number of ops:  8
compiled vars:  !0 = $achievement
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
   34     1        FETCH_OBJ_R                                          ~1      !0, 'criteria'
          2        FETCH_OBJ_R                                          ~2      ~1, 'is_completed'
          3        TYPE_CHECK                                        8  ~3      ~2
          4        VERIFY_RETURN_TYPE                                           ~3
          5      > RETURN                                                       ~3
   35     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.71 ms | 2118 KiB | 17 Q