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) { preg_match('/src=\"[\\w\\:\\/\\.]+photo\\/(?<url>[^[:space:]\"]+)/i', $item, $matches); return isset($matches['url']) ? $matches['url'] : false; }, $feed['feed_image']); // remove all items that had no url matched. Remove this line if you know that there is always a match $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/uHE99
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%2FuHE99%3A16%240'
   19    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
   19    18        OP_DATA                                                  $15
   21    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
   25    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FuHE99%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uHE99
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $item, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2Fsrc%3D%5C%22%5B%5Cw%5C%3A%5C%2F%5C.%5D%2Bphoto%5C%2F%28%3F%3Curl%3E%5B%5E%5B%3Aspace%3A%5D%5C%22%5D%2B%29%2Fi'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   18     6        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'url'
          7      > JMPZ                                                     ~3, ->11
          8    >   FETCH_DIM_R                                      ~4      !1, 'url'
          9        QM_ASSIGN                                        ~5      ~4
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~5      <false>
         12    > > RETURN                                                   ~5
   19    13*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.09 ms | 1400 KiB | 21 Q