3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '{ "text": "Test Text", "truncated": false, "entities": { "media": [ { "media_url": "http:\/\/pbs.twimg.com\/media\/34453543545.jpg", "media_url_https": "https:\/\/pbs.twimg.com\/media\/34453543545.jpg", "type": "photo", "sizes": { "thumb": { "w": 150, "h": 150, "resize": "crop" } } },{ "media_url": "http:\/\/pbs.twimg.com\/media\/3123.jpg", "media_url_https": "https:\/\/pbs.twimg.com\/media\/34453543545.jpg", "type": "photo", "sizes": { "thumb": { "w": 150, "h": 150, "resize": "crop" } } } ] } }'; $results = json_decode($str); $media_url = function() use($results) { foreach ($results->entities->media as $item) { yield $item->media_url; } }; // get first echo $media_url()->current().PHP_EOL; // or loop foreach ($media_url() as $item){ echo $item.PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/DQePR
function name:  (null)
number of ops:  23
compiled vars:  !0 = $str, !1 = $results, !2 = $media_url, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%0A++%22text%22%3A+%22Test+Text%22%2C%0A++%22truncated%22%3A+false%2C%0A++%22entities%22%3A+%7B%0A++++%22media%22%3A+%5B%0A++++++%7B%0A++++++++%22media_url%22%3A+%22http%3A%5C%2F%5C%2Fpbs.twimg.com%5C%2Fmedia%5C%2F34453543545.jpg%22%2C%0A++++++++%22media_url_https%22%3A+%22https%3A%5C%2F%5C%2Fpbs.twimg.com%5C%2Fmedia%5C%2F34453543545.jpg%22%2C%0A++++++++%22type%22%3A+%22photo%22%2C%0A++++++++%22sizes%22%3A+%7B%0A++++++++++%22thumb%22%3A+%7B%0A++++++++++++%22w%22%3A+150%2C%0A++++++++++++%22h%22%3A+150%2C%0A++++++++++++%22resize%22%3A+%22crop%22%0A++++++++++%7D%0A++++++++%7D%0A++++++%7D%2C%7B%0A++++++++%22media_url%22%3A+%22http%3A%5C%2F%5C%2Fpbs.twimg.com%5C%2Fmedia%5C%2F3123.jpg%22%2C%0A++++++++%22media_url_https%22%3A+%22https%3A%5C%2F%5C%2Fpbs.twimg.com%5C%2Fmedia%5C%2F34453543545.jpg%22%2C%0A++++++++%22type%22%3A+%22photo%22%2C%0A++++++++%22sizes%22%3A+%7B%0A++++++++++%22thumb%22%3A+%7B%0A++++++++++++%22w%22%3A+150%2C%0A++++++++++++%22h%22%3A+150%2C%0A++++++++++++%22resize%22%3A+%22crop%22%0A++++++++++%7D%0A++++++++%7D%0A++++++%7D%0A++++%5D%0A++%7D%0A%7D'
   34     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !1, $5
   36     5        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          6        BIND_LEXICAL                                             ~7, !1
          7        ASSIGN                                                   !2, ~7
   43     8        INIT_DYNAMIC_CALL                                        !2
          9        DO_FCALL                                      0  $9      
         10        INIT_METHOD_CALL                                         $9, 'current'
         11        DO_FCALL                                      0  $10     
         12        CONCAT                                           ~11     $10, '%0A'
         13        ECHO                                                     ~11
   46    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0  $12     
         16      > FE_RESET_R                                       $13     $12, ->21
         17    > > FE_FETCH_R                                               $13, !3, ->21
   47    18    >   CONCAT                                           ~14     !3, '%0A'
         19        ECHO                                                     ~14
   46    20      > JMP                                                      ->17
         21    >   FE_FREE                                                  $13
   48    22      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/DQePR
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $results, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   GENERATOR_CREATE                                         
          1        BIND_STATIC                                              !0
   37     2        FETCH_OBJ_R                                      ~2      !0, 'entities'
          3        FETCH_OBJ_R                                      ~3      ~2, 'media'
          4      > FE_RESET_R                                       $4      ~3, ->9
          5    > > FE_FETCH_R                                               $4, !1, ->9
   38     6    >   FETCH_OBJ_R                                      ~5      !1, 'media_url'
          7        YIELD                                                    ~5
   37     8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $4
   40    10      > GENERATOR_RETURN                                         

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.28 ms | 1007 KiB | 14 Q