3v4l.org

run code in 300+ PHP versions simultaneously
<?php $phrases = array("NEW YORK NY", "NEW JERSEY", "SOUTH DAKOTA", "SOUTH CAROLINA", "COMPUTER REPAIR TECH","YORK NY","07728","WYOMING MI","WYOMING MINNESOTA"); $string = ("I live in wyoming Minnesota, but used to live in New Jersey 07728 working as a computer repair tech."); $string = strtoupper($string); $matches = stringSearch($phrases, $string); function stringSearch($phrases, $string){ $phrases1 = trim(implode('|', $phrases)); $phrases1 = str_replace(' ', '\s', $phrases1); preg_match_all("/$phrases1/s", $string, $matches); $value = implode(' ', array_filter($matches[0])); echo $value; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yi0Gd
function name:  (null)
number of ops:  12
compiled vars:  !0 = $phrases, !1 = $string, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'I+live+in+wyoming+Minnesota%2C+but+used+to+live+in+New+Jersey+07728+working+++++as+a+computer+repair+tech.'
    5     2        INIT_FCALL                                               'strtoupper'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    7     6        INIT_FCALL_BY_NAME                                       'stringSearch'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   18    11      > RETURN                                                   1

Function stringsearch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yi0Gd
function name:  stringSearch
number of ops:  35
compiled vars:  !0 = $phrases, !1 = $string, !2 = $phrases1, !3 = $matches, !4 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'trim'
          3        INIT_FCALL                                               'implode'
          4        SEND_VAL                                                 '%7C'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   11    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '+'
         12        SEND_VAL                                                 '%5Cs'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $8      
         15        ASSIGN                                                   !2, $8
   13    16        INIT_FCALL                                               'preg_match_all'
         17        ROPE_INIT                                     3  ~11     '%2F'
         18        ROPE_ADD                                      1  ~11     ~11, !2
         19        ROPE_END                                      2  ~10     ~11, '%2Fs'
         20        SEND_VAL                                                 ~10
         21        SEND_VAR                                                 !1
         22        SEND_REF                                                 !3
         23        DO_ICALL                                                 
   15    24        INIT_FCALL                                               'implode'
         25        SEND_VAL                                                 '+'
         26        INIT_FCALL                                               'array_filter'
         27        FETCH_DIM_R                                      ~14     !3, 0
         28        SEND_VAL                                                 ~14
         29        DO_ICALL                                         $15     
         30        SEND_VAR                                                 $15
         31        DO_ICALL                                         $16     
         32        ASSIGN                                                   !4, $16
   16    33        ECHO                                                     !4
   18    34      > RETURN                                                   null

End of function stringsearch

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.77 ms | 1400 KiB | 25 Q