3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = <<<URLS https://example.com/cost-center/sub-one/sub-two/article-3/ https://example.com/cost-center/sub-one/sub-three/article-4 https://example.com/cost-center/sub-1/sub-two/sub-three/article-5/ 'https://example.com/cost-center/sub-one/sub-two/article-3/' 'https://example.com/cost-center/sub-1/sub-two/sub-three/article-5' "https://example.com/cost-center/sub-one/sub-three/article-4" "https://example.com/cost-center/sub-1/sub-two/sub-three/article-5/" URLS; echo preg_replace('#https://[^/]+/cost-center/\K([^/\s]+/)+(?=article)#', 'test/', $test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uC9ZR
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Fexample.com%2Fcost-center%2Fsub-one%2Fsub-two%2Farticle-3%2F%0Ahttps%3A%2F%2Fexample.com%2Fcost-center%2Fsub-one%2Fsub-three%2Farticle-4%0Ahttps%3A%2F%2Fexample.com%2Fcost-center%2Fsub-1%2Fsub-two%2Fsub-three%2Farticle-5%2F%0A%27https%3A%2F%2Fexample.com%2Fcost-center%2Fsub-one%2Fsub-two%2Farticle-3%2F%27%0A%27https%3A%2F%2Fexample.com%2Fcost-center%2Fsub-1%2Fsub-two%2Fsub-three%2Farticle-5%27%0A%22https%3A%2F%2Fexample.com%2Fcost-center%2Fsub-one%2Fsub-three%2Farticle-4%22%0A%22https%3A%2F%2Fexample.com%2Fcost-center%2Fsub-1%2Fsub-two%2Fsub-three%2Farticle-5%2F%22'
   13     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%23https%3A%2F%2F%5B%5E%2F%5D%2B%2Fcost-center%2F%5CK%28%5B%5E%2F%5Cs%5D%2B%2F%29%2B%28%3F%3Darticle%29%23'
          3        SEND_VAL                                                 'test%2F'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ECHO                                                     $2
          7      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.22 ms | 1009 KiB | 14 Q