3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data=array(array('name'=>'ahmed','job'=>'engineer','age'=>25,'hobbies'=>array('drawing','swimming','reading'),'skills'=>array('coding','fasting learning','teaching')),array('name'=>'Sara','job'=>'designer','age'=>19,'skills'=>array('fast learning')),array('name'=>'Ali','age'=>25,'city'=>'cairo'),array('name'=>'Hossam','job'=>'accountant','age'=>25,'city'=>'zagazig'),array('name'=>'Esraa','job'=>'Designer','age'=>23,'city'=>'zagazig','hobbies'=>array('writing','reading'),'skills'=>array('coding','teaching')),); $search_string = 'zagazig'; $results = array(); foreach($data as $value) { if( !empty($value['city']) && (stripos($value['city'], $search_string) !== false) ) { $results[] = $value; } } if(!empty($results)) { echo 'Number of results: ' , count($results), PHP_EOL, ' Result ', PHP_EOL; foreach($results as $r) { echo " Name: {$r['name']} Job: {$r['job']} Age: {$r['age']} ", PHP_EOL; echo !empty($r['hobbies']) ? PHP_EOL . 'Hobbies: ' . PHP_EOL . implode(PHP_EOL, $r['hobbies']) : ''; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 55
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 54
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 54
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 51
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 55
Branch analysis from position: 19
filename:       /in/cMom5
function name:  (null)
number of ops:  56
compiled vars:  !0 = $data, !1 = $search_string, !2 = $results, !3 = $value, !4 = $r
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1        ASSIGN                                                       !1, 'zagazig'
    6     2        ASSIGN                                                       !2, <array>
    7     3      > FE_RESET_R                                           $8      !0, ->19
          4    > > FE_FETCH_R                                                   $8, !3, ->19
    9     5    >   ISSET_ISEMPTY_DIM_OBJ                             1  ~9      !3, 'city'
          6        BOOL_NOT                                             ~10     ~9
          7      > JMPZ_EX                                              ~10     ~10, ->15
   10     8    >   INIT_FCALL                                                   'stripos'
          9        FETCH_DIM_R                                          ~11     !3, 'city'
         10        SEND_VAL                                                     ~11
         11        SEND_VAR                                                     !1
         12        DO_ICALL                                             $12     
         13        TYPE_CHECK                                      1018  ~13     $12
         14        BOOL                                                 ~10     ~13
         15    > > JMPZ                                                         ~10, ->18
   12    16    >   ASSIGN_DIM                                                   !2
         17        OP_DATA                                                      !3
    7    18    > > JMP                                                          ->4
         19    >   FE_FREE                                                      $8
   17    20        ISSET_ISEMPTY_CV                                     ~15     !2
         21        BOOL_NOT                                             ~16     ~15
         22      > JMPZ                                                         ~16, ->55
   18    23    >   ECHO                                                         'Number+of+results%3A+'
         24        COUNT                                                ~17     !2
         25        ECHO                                                         ~17
         26        ECHO                                                         '%0A'
         27        ECHO                                                         '+Result+'
         28        ECHO                                                         '%0A'
   19    29      > FE_RESET_R                                           $18     !2, ->54
         30    > > FE_FETCH_R                                                   $18, !4, ->54
   20    31    >   ROPE_INIT                                         7  ~23     '%0A%09%09Name%3A+'
   21    32        FETCH_DIM_R                                          ~19     !4, 'name'
         33        ROPE_ADD                                          1  ~23     ~23, ~19
         34        ROPE_ADD                                          2  ~23     ~23, '%0A%09%09Job%3A+'
   22    35        FETCH_DIM_R                                          ~20     !4, 'job'
         36        ROPE_ADD                                          3  ~23     ~23, ~20
         37        ROPE_ADD                                          4  ~23     ~23, '%0A%09%09Age%3A+'
   23    38        FETCH_DIM_R                                          ~21     !4, 'age'
         39        ROPE_ADD                                          5  ~23     ~23, ~21
         40        ROPE_END                                          6  ~22     ~23, '%0A%09%09'
         41        ECHO                                                         ~22
   24    42        ECHO                                                         '%0A'
   25    43        ISSET_ISEMPTY_DIM_OBJ                             1  ~27     !4, 'hobbies'
         44        BOOL_NOT                                             ~28     ~27
         45      > JMPZ                                                         ~28, ->51
         46    >   FETCH_DIM_R                                          ~29     !4, 'hobbies'
         47        FRAMELESS_ICALL_2                implode             ~30     '%0A', ~29
         48        CONCAT                                               ~31     '%0AHobbies%3A+%0A', ~30
         49        QM_ASSIGN                                            ~32     ~31
         50      > JMP                                                          ->52
         51    >   QM_ASSIGN                                            ~32     ''
         52    >   ECHO                                                         ~32
   19    53      > JMP                                                          ->30
         54    >   FE_FREE                                                      $18
   27    55    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.52 ms | 2279 KiB | 14 Q