3v4l.org

run code in 300+ PHP versions simultaneously
<?php $types = array( 'jsfiddle' => array( array( 'https?:\/\/(?:www)?\.?jsfiddle\.net[\w\/-]*\/([a-z\d]{8}(?:\/\d+)?)\/?', '<div class="jsfiddle-embed-wrap"><iframe class="iframe-jsfiddle" src="//jsfiddle.net/$1/embedded/result,js,html,css/"></iframe></div>' ), ), // youtube, replit, ... ); $text = 'https://jsfiddle.net/kai_noack/h1jf34za/11/'; foreach($types as $t => $ra) { // $t is youtube, jsfiddle, replit // $ra is array with replacements $ra[0] regex, $ra[1] embed code foreach($ra as $r) { $text = preg_replace('/<a[^>]+>'.$r[0].'<\/a>/i', $r[1], $text); $text = preg_replace('/(?<![\'"=])'.$r[0].'/i', $r[1], $text); } } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/Rm6hv
function name:  (null)
number of ops:  33
compiled vars:  !0 = $types, !1 = $text, !2 = $ra, !3 = $t, !4 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, 'https%3A%2F%2Fjsfiddle.net%2Fkai_noack%2Fh1jf34za%2F11%2F'
   14     2      > FE_RESET_R                                       $7      !0, ->30
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->30
          4    >   ASSIGN                                                   !3, ~8
   17     5      > FE_RESET_R                                       $10     !2, ->28
          6    > > FE_FETCH_R                                               $10, !4, ->28
   18     7    >   INIT_FCALL                                               'preg_replace'
          8        FETCH_DIM_R                                      ~11     !4, 0
          9        CONCAT                                           ~12     '%2F%3Ca%5B%5E%3E%5D%2B%3E', ~11
         10        CONCAT                                           ~13     ~12, '%3C%5C%2Fa%3E%2Fi'
         11        SEND_VAL                                                 ~13
         12        FETCH_DIM_R                                      ~14     !4, 1
         13        SEND_VAL                                                 ~14
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $15     
         16        ASSIGN                                                   !1, $15
   19    17        INIT_FCALL                                               'preg_replace'
         18        FETCH_DIM_R                                      ~17     !4, 0
         19        CONCAT                                           ~18     '%2F%28%3F%3C%21%5B%27%22%3D%5D%29', ~17
         20        CONCAT                                           ~19     ~18, '%2Fi'
         21        SEND_VAL                                                 ~19
         22        FETCH_DIM_R                                      ~20     !4, 1
         23        SEND_VAL                                                 ~20
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $21     
         26        ASSIGN                                                   !1, $21
   17    27      > JMP                                                      ->6
         28    >   FE_FREE                                                  $10
   14    29      > JMP                                                      ->3
         30    >   FE_FREE                                                  $7
   22    31        ECHO                                                     !1
   23    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.32 ms | 1401 KiB | 15 Q