3v4l.org

run code in 300+ PHP versions simultaneously
<?php $feeds = [ ['feed_image' => [ '<a href="http://52.1.47.143/photo/928/2_onclick_ok/userid_244/" class=" js_photo_item_928 photo_holder_image" rel="928" ><img src="http://52.1.47.143/file/pic/photo/2015/04/9bd387c6442135834298d6a17b3f9555_240.jpg" alt="" width="180" height="160" class="photo_holder" /></a><br />', '<a href="http://52.1.47.143/photo/927/8/userid_244/" class=" js_photo_item_928 photo_holder_image" rel="927"><img src="http://52.1.47.143/file/pic/photo/2015/04/6eb60ee0e258223ef72a9a632d0ce429_240.png" alt="" height="84" width="150" class="photo_holder" userid="244" /></a>', 'hufflebuff' ] ], ['some other array'] ]; $result = []; foreach($feeds as $index => $feed) { if(isset($feed['feed_image']) && is_array($feed['feed_image'])) { $result[$index] = array_map(function($item) { $dom = new DOMDocument; $dom->loadHtml($item); $src = simplexml_import_dom($dom)->xpath('//img/@src'); if(!isset($src[0])) { return false; } $components = explode('photo/', $src[0]); return end($components); }, $feed['feed_image']); $result[$index] = array_filter($result[$index]); } } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
Branch analysis from position: 10
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/sUihr
function name:  (null)
number of ops:  31
compiled vars:  !0 = $feeds, !1 = $result, !2 = $feed, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   14     2      > FE_RESET_R                                       $6      !0, ->26
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->26
          4    >   ASSIGN                                                   !3, ~7
   15     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !2, 'feed_image'
          6      > JMPZ_EX                                          ~9      ~9, ->10
          7    >   FETCH_DIM_R                                      ~10     !2, 'feed_image'
          8        TYPE_CHECK                                  128  ~11     ~10
          9        BOOL                                             ~9      ~11
         10    > > JMPZ                                                     ~9, ->25
   16    11    >   INIT_FCALL                                               'array_map'
         12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FsUihr%3A16%240'
   25    13        SEND_VAL                                                 ~13
         14        FETCH_DIM_R                                      ~14     !2, 'feed_image'
         15        SEND_VAL                                                 ~14
         16        DO_ICALL                                         $15     
   16    17        ASSIGN_DIM                                               !1, !3
   25    18        OP_DATA                                                  $15
   26    19        INIT_FCALL                                               'array_filter'
         20        FETCH_DIM_R                                      ~17     !1, !3
         21        SEND_VAL                                                 ~17
         22        DO_ICALL                                         $18     
         23        ASSIGN_DIM                                               !1, !3
         24        OP_DATA                                                  $18
   14    25    > > JMP                                                      ->3
         26    >   FE_FREE                                                  $6
   30    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FsUihr%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sUihr
function name:  {closure}
number of ops:  29
compiled vars:  !0 = $item, !1 = $dom, !2 = $src, !3 = $components
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        NEW                                              $4      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   18     4        INIT_METHOD_CALL                                         !1, 'loadHtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   19     7        INIT_FCALL                                               'simplexml_import_dom'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $8      
         10        INIT_METHOD_CALL                                         $8, 'xpath'
         11        SEND_VAL_EX                                              '%2F%2Fimg%2F%40src'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
   20    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !2, 0
         15        BOOL_NOT                                         ~12     ~11
         16      > JMPZ                                                     ~12, ->18
   21    17    > > RETURN                                                   <false>
   23    18    >   INIT_FCALL                                               'explode'
         19        SEND_VAL                                                 'photo%2F'
         20        FETCH_DIM_R                                      ~13     !2, 0
         21        SEND_VAL                                                 ~13
         22        DO_ICALL                                         $14     
         23        ASSIGN                                                   !3, $14
   24    24        INIT_FCALL                                               'end'
         25        SEND_REF                                                 !3
         26        DO_ICALL                                         $16     
         27      > RETURN                                                   $16
   25    28*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FsUihr%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.73 ms | 1400 KiB | 25 Q