3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _grep($results_array, $q) { foreach($results_array as &$row) { $row = explode(',', $row); } unset($row); $results_array = call_user_func_array('array_merge_recursive', $results_array); // HERE IS CHANGED **** $q = preg_split('/\s+/', trim($q)); foreach ($results_array as $key => $value) { foreach ($q as $qeury) { if (stripos($value, $qeury) === false) { unset($results_array[$key]); break; } } } // **** $results_array = array_values($results_array); return $results_array; } $results_array = array( 'php,mysql,jquery,ruby,html,css,lamp', 'mouse,keyboard,laptop,pad', 'table,sofa,caption', 'control,television,control television,television control', ); var_dump(_grep($results_array, 'tele co'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5SCJb
function name:  (null)
number of ops:  9
compiled vars:  !0 = $results_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   29     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               '_grep'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'tele+co'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function _grep:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 39
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 39
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 39
Branch analysis from position: 39
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 10
filename:       /in/5SCJb
function name:  _grep
number of ops:  48
compiled vars:  !0 = $results_array, !1 = $q, !2 = $row, !3 = $value, !4 = $key, !5 = $qeury
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2      > FE_RESET_RW                                      $6      !0, ->10
          3    > > FE_FETCH_RW                                              $6, !2, ->10
    5     4    >   INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2C'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !2, $7
    4     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $6
    7    11        UNSET_CV                                                 !2
    8    12        INIT_FCALL                                               'array_merge_recursive'
         13        SEND_ARRAY                                               !0
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !0, $9
   10    17        INIT_FCALL                                               'preg_split'
         18        SEND_VAL                                                 '%2F%5Cs%2B%2F'
         19        INIT_FCALL                                               'trim'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !1, $12
   11    25      > FE_RESET_R                                       $14     !0, ->41
         26    > > FE_FETCH_R                                       ~15     $14, !3, ->41
         27    >   ASSIGN                                                   !4, ~15
   12    28      > FE_RESET_R                                       $17     !1, ->39
         29    > > FE_FETCH_R                                               $17, !5, ->39
   13    30    >   INIT_FCALL                                               'stripos'
         31        SEND_VAR                                                 !3
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $18     
         34        TYPE_CHECK                                    4          $18
         35      > JMPZ                                                     ~19, ->38
   14    36    >   UNSET_DIM                                                !0, !4
   15    37      > JMP                                                      ->39
   12    38    > > JMP                                                      ->29
         39    >   FE_FREE                                                  $17
   11    40      > JMP                                                      ->26
         41    >   FE_FREE                                                  $14
   20    42        INIT_FCALL                                               'array_values'
         43        SEND_VAR                                                 !0
         44        DO_ICALL                                         $20     
         45        ASSIGN                                                   !0, $20
   21    46      > RETURN                                                   !0
   22    47*     > RETURN                                                   null

End of function _grep

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.74 ms | 1402 KiB | 28 Q