3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array('Dogs/Cats', 'Dogs/Cats/Mice', 'ANIMALS/SPECIES Dogs/Cats/Mice', '(Animals/Species) Dogs/Cats/Mice'); $re = '~(?:^(?:\(\w+/\w+\)\h+|[A-Z]+/[A-Z]+\h+)?|\G(?!^))\w+\K/~'; $array = preg_replace($re, " or ", $array); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fkXnA
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array, !1 = $re
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, '%7E%28%3F%3A%5E%28%3F%3A%5C%28%5Cw%2B%2F%5Cw%2B%5C%29%5Ch%2B%7C%5BA-Z%5D%2B%2F%5BA-Z%5D%2B%5Ch%2B%29%3F%7C%5CG%28%3F%21%5E%29%29%5Cw%2B%5CK%2F%7E'
    5     2        FRAMELESS_ICALL_3                preg_replace        ~4      !1, '+or+'
          3        OP_DATA                                                      !0
          4        ASSIGN                                                       !0, ~4
    6     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
132.72 ms | 2069 KiB | 16 Q