3v4l.org

run code in 300+ 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:  12
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        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '+or+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
    6     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.75 ms | 1013 KiB | 15 Q