3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str1 = "Samsung Television 21 Television new Television new 21 Inches sdds LED BH005DE"; $str2 = "Samsung 21 Inch LED TV"; $syns = [ 'tv' => ['sdds', 'Television new', 'Television11'] //'inch' => ['Inches'] ]; $str1 = array_reduce(array_keys($syns), function($c, $x) use ($syns) { return $c = preg_replace('/\b'.join('\b|\b', $syns[$x]).'\b/', $x, $c); }, $str1); $arr1 = explode(' ', $str1); var_dump($arr1); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZLuTg
function name:  (null)
number of ops:  23
compiled vars:  !0 = $str1, !1 = $str2, !2 = $syns, !3 = $arr1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, 'Samsung+Television+21+Television+new+Television+new+21+Inches+sdds+LED+BH005DE'
    6     1        ASSIGN                                                   !1, 'Samsung+21+Inch+LED+TV'
    9     2        ASSIGN                                                   !2, <array>
   16     3        INIT_FCALL                                               'array_reduce'
          4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $7      
          7        SEND_VAR                                                 $7
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZLuTg%3A16%240'
          9        BIND_LEXICAL                                             ~8, !2
   19    10        SEND_VAL                                                 ~8
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $9      
   16    13        ASSIGN                                                   !0, $9
   26    14        INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '+'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $11     
         18        ASSIGN                                                   !3, $11
   28    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                                 
   30    22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZLuTg%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZLuTg
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $c, !1 = $x, !2 = $syns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   18     3        INIT_FCALL                                               'preg_replace'
          4        INIT_FCALL                                               'join'
          5        SEND_VAL                                                 '%5Cb%7C%5Cb'
          6        FETCH_DIM_R                                      ~3      !2, !1
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        CONCAT                                           ~5      '%2F%5Cb', $4
         10        CONCAT                                           ~6      ~5, '%5Cb%2F'
         11        SEND_VAL                                                 ~6
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $7      
         15        ASSIGN                                           ~8      !0, $7
         16      > RETURN                                                   ~8
   19    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZLuTg%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.2 ms | 1400 KiB | 25 Q