3v4l.org

run code in 500+ PHP versions simultaneously
<?php function stripEmptyTags ($result) { $regexps = array ( '~<(\w+)\b[^\>]*>([\s]|&nbsp;)*</\\1>~', '~<\w+\s*/>~', ); do { $string = $result; $result = preg_replace ($regexps, '', $string); } while ($result != $string); return $result; } function extractEmbedYT($str) { // Find all URLS in $str preg_match_all('/(\bhttps?:)?\/\/[^,\s()<>]+(?:\(\w+\)|(?:[^,[:punct:]\s]|\/))/s', $str, $matches); // Remove all iframes from $str $str = preg_replace('/<iframe.*?<\/iframe>/i','', $str); $str = stripEmptyTags($str); return [$str, $matches[0]]; } $string = '<p> </p><p>UDA Stagiaire</p><p><iframe width="560" height="315" src="//www.youtube.com/embed/PZlJFGgFTfA" frameborder="0" allowfullscreen=""></iframe></p>'; $results = extractEmbedYT($string); print_r($results);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OFDf
function name:  (null)
number of ops:  9
compiled vars:  !0 = $string, !1 = $results
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   ASSIGN                                                       !0, '%3Cp%3E%0A++%0A%3C%2Fp%3E%3Cp%3EUDA+Stagiaire%3C%2Fp%3E%3Cp%3E%3Ciframe+width%3D%22560%22+height%3D%22315%22+src%3D%22%2F%2Fwww.youtube.com%2Fembed%2FPZlJFGgFTfA%22+frameborder%3D%220%22+allowfullscreen%3D%22%22%3E%3C%2Fiframe%3E%3C%2Fp%3E'
   38     1        INIT_FCALL                                                   'extractembedyt'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !1, $3
   40     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function stripemptytags:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
filename:       /in/1OFDf
function name:  stripEmptyTags
number of ops:  10
compiled vars:  !0 = $result, !1 = $regexps, !2 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        ASSIGN                                                       !1, <array>
   12     2    >   ASSIGN                                                       !2, !0
   13     3        FRAMELESS_ICALL_3                preg_replace        ~5      !1, ''
          4        OP_DATA                                                      !2
          5        ASSIGN                                                       !0, ~5
   15     6        IS_NOT_EQUAL                                                 !0, !2
          7      > JMPNZ                                                        ~7, ->2
   17     8    > > RETURN                                                       !0
   18     9*     > RETURN                                                       null

End of function stripemptytags

Function extractembedyt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OFDf
function name:  extractEmbedYT
number of ops:  18
compiled vars:  !0 = $str, !1 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
   24     1        INIT_FCALL                                                   'preg_match_all'
          2        SEND_VAL                                                     '%2F%28%5Cbhttps%3F%3A%29%3F%5C%2F%5C%2F%5B%5E%2C%5Cs%28%29%3C%3E%5D%2B%28%3F%3A%5C%28%5Cw%2B%5C%29%7C%28%3F%3A%5B%5E%2C%5B%3Apunct%3A%5D%5Cs%5D%7C%5C%2F%29%29%2Fs'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !1
          5        DO_ICALL                                                     
   27     6        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%3Ciframe.%2A%3F%3C%5C%2Fiframe%3E%2Fi', ''
          7        OP_DATA                                                      !0
          8        ASSIGN                                                       !0, ~3
   30     9        INIT_FCALL                                                   'stripemptytags'
         10        SEND_VAR                                                     !0
         11        DO_FCALL                                          0  $5      
         12        ASSIGN                                                       !0, $5
   31    13        INIT_ARRAY                                           ~7      !0
         14        FETCH_DIM_R                                          ~8      !1, 0
         15        ADD_ARRAY_ELEMENT                                    ~7      ~8
         16      > RETURN                                                       ~7
   32    17*     > RETURN                                                       null

End of function extractembedyt

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.02 ms | 2647 KiB | 17 Q