3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mysql_result[0]['id']="1"; $mysql_result[1]['id']="2"; $mysql_result[2]['id']="3"; $mysql_result[0]['address']="www.example.com/page1"; $mysql_result[1]['address']="www.example.com/page2"; $mysql_result[2]['address']="www.example.com/page3"; $mysql_result[0]['title']="Page 1"; $mysql_result[1]['title']="Page 2"; $mysql_result[2]['title']="Page 3"; $mysql_result[0]['content']="The quick dog jumps over the lazy dog."; $mysql_result[1]['content']="The best thing about morning is breakfast."; $mysql_result[2]['content']="Hotdogs are great ballpark food."; $mysql_result[0]['image']="image1.jpg"; $mysql_result[1]['image']="image2.jpg"; $mysql_result[2]['image']="image3.jpg"; $query="dog"; foreach($mysql_result as $results) { $content = str_replace($query,"my_un1qu3_r3pl4c3m3nt_".$query,$results['content']); $occurences = explode("my_un1qu3_r3pl4c3m3nt_",$content); $position_in_original_content = 0; foreach($occurences as $an_occurence) { echo "the occurence: $an_occurence\nThe position $position_in_original_content\n"; if (strpos($an_occurence,$query) !== false) { $content=$an_occurence; echo '<li class="media"> <a class="pull-left" href="'.$results['address'].'"> <img class="media-object thumbnail" src="'.$results['image'].'" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="'.$results['address'].'">'.$results['title'].'</a></h4> <p>...'.str_replace($query,'<strong>'.$query.'</strong>', substr($results['content'],$position_in_original_content-10,($position_in_original_content+strlen($an_occurence)+10))).'...</p> </div>'.($position_in_original_content-0).' and '.(strlen($an_occurence)+0).' </li>'; } $position_in_original_content = $position_in_original_content+strlen($an_occurence); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 122
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 122
Branch analysis from position: 48
2 jumps found. (Code = 77) Position 1 = 63, Position 2 = 120
Branch analysis from position: 63
2 jumps found. (Code = 78) Position 1 = 64, Position 2 = 120
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 116
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 116
Branch analysis from position: 120
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 120
Branch analysis from position: 122
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 122
filename:       /in/5Tdlo
function name:  (null)
number of ops:  124
compiled vars:  !0 = $mysql_result, !1 = $query, !2 = $results, !3 = $content, !4 = $occurences, !5 = $position_in_original_content, !6 = $an_occurence
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_DIM_W                                      $7      !0, 0
          1        ASSIGN_DIM                                               $7, 'id'
          2        OP_DATA                                                  '1'
    4     3        FETCH_DIM_W                                      $9      !0, 1
          4        ASSIGN_DIM                                               $9, 'id'
          5        OP_DATA                                                  '2'
    5     6        FETCH_DIM_W                                      $11     !0, 2
          7        ASSIGN_DIM                                               $11, 'id'
          8        OP_DATA                                                  '3'
    7     9        FETCH_DIM_W                                      $13     !0, 0
         10        ASSIGN_DIM                                               $13, 'address'
         11        OP_DATA                                                  'www.example.com%2Fpage1'
    8    12        FETCH_DIM_W                                      $15     !0, 1
         13        ASSIGN_DIM                                               $15, 'address'
         14        OP_DATA                                                  'www.example.com%2Fpage2'
    9    15        FETCH_DIM_W                                      $17     !0, 2
         16        ASSIGN_DIM                                               $17, 'address'
         17        OP_DATA                                                  'www.example.com%2Fpage3'
   11    18        FETCH_DIM_W                                      $19     !0, 0
         19        ASSIGN_DIM                                               $19, 'title'
         20        OP_DATA                                                  'Page+1'
   12    21        FETCH_DIM_W                                      $21     !0, 1
         22        ASSIGN_DIM                                               $21, 'title'
         23        OP_DATA                                                  'Page+2'
   13    24        FETCH_DIM_W                                      $23     !0, 2
         25        ASSIGN_DIM                                               $23, 'title'
         26        OP_DATA                                                  'Page+3'
   15    27        FETCH_DIM_W                                      $25     !0, 0
         28        ASSIGN_DIM                                               $25, 'content'
         29        OP_DATA                                                  'The+quick+dog+jumps+over+the+lazy+dog.'
   16    30        FETCH_DIM_W                                      $27     !0, 1
         31        ASSIGN_DIM                                               $27, 'content'
         32        OP_DATA                                                  'The+best+thing+about+morning+is+breakfast.'
   17    33        FETCH_DIM_W                                      $29     !0, 2
         34        ASSIGN_DIM                                               $29, 'content'
         35        OP_DATA                                                  'Hotdogs+are+great+ballpark+food.'
   19    36        FETCH_DIM_W                                      $31     !0, 0
         37        ASSIGN_DIM                                               $31, 'image'
         38        OP_DATA                                                  'image1.jpg'
   20    39        FETCH_DIM_W                                      $33     !0, 1
         40        ASSIGN_DIM                                               $33, 'image'
         41        OP_DATA                                                  'image2.jpg'
   21    42        FETCH_DIM_W                                      $35     !0, 2
         43        ASSIGN_DIM                                               $35, 'image'
         44        OP_DATA                                                  'image3.jpg'
   24    45        ASSIGN                                                   !1, 'dog'
   26    46      > FE_RESET_R                                       $38     !0, ->122
         47    > > FE_FETCH_R                                               $38, !2, ->122
   29    48    >   INIT_FCALL                                               'str_replace'
         49        SEND_VAR                                                 !1
         50        CONCAT                                           ~39     'my_un1qu3_r3pl4c3m3nt_', !1
         51        SEND_VAL                                                 ~39
         52        FETCH_DIM_R                                      ~40     !2, 'content'
         53        SEND_VAL                                                 ~40
         54        DO_ICALL                                         $41     
         55        ASSIGN                                                   !3, $41
   31    56        INIT_FCALL                                               'explode'
         57        SEND_VAL                                                 'my_un1qu3_r3pl4c3m3nt_'
         58        SEND_VAR                                                 !3
         59        DO_ICALL                                         $43     
         60        ASSIGN                                                   !4, $43
   32    61        ASSIGN                                                   !5, 0
   34    62      > FE_RESET_R                                       $46     !4, ->120
         63    > > FE_FETCH_R                                               $46, !6, ->120
   37    64    >   ROPE_INIT                                     5  ~48     'the+occurence%3A+'
         65        ROPE_ADD                                      1  ~48     ~48, !6
         66        ROPE_ADD                                      2  ~48     ~48, '%0AThe+position+'
         67        ROPE_ADD                                      3  ~48     ~48, !5
         68        ROPE_END                                      4  ~47     ~48, '%0A'
         69        ECHO                                                     ~47
   40    70        INIT_FCALL                                               'strpos'
         71        SEND_VAR                                                 !6
         72        SEND_VAR                                                 !1
         73        DO_ICALL                                         $51     
         74        TYPE_CHECK                                  1018          $51
         75      > JMPZ                                                     ~52, ->116
   42    76    >   ASSIGN                                                   !3, !6
   45    77        FETCH_DIM_R                                      ~54     !2, 'address'
         78        CONCAT                                           ~55     '%3Cli+class%3D%22media%22%3E%0A++++++++++++%3Ca+class%3D%22pull-left%22+href%3D%22', ~54
         79        CONCAT                                           ~56     ~55, '%22%3E%0A++++++++++++%3Cimg+class%3D%22media-object+thumbnail%22+src%3D%22'
   46    80        FETCH_DIM_R                                      ~57     !2, 'image'
         81        CONCAT                                           ~58     ~56, ~57
         82        CONCAT                                           ~59     ~58, '%22+style%3D%22height%3A100px+%21important%22%3E%0A++++++++++++%3C%2Fa%3E%0A++++++++++++%3Cdiv+class%3D%22media-body%22%3E%0A++++++++++++++%3Ch4+class%3D%22media-heading%22%3E%3Ca+href%3D%22'
   49    83        FETCH_DIM_R                                      ~60     !2, 'address'
         84        CONCAT                                           ~61     ~59, ~60
         85        CONCAT                                           ~62     ~61, '%22%3E'
         86        FETCH_DIM_R                                      ~63     !2, 'title'
         87        CONCAT                                           ~64     ~62, ~63
         88        CONCAT                                           ~65     ~64, '%3C%2Fa%3E%3C%2Fh4%3E%0A++++++++++++++%3Cp%3E...'
   50    89        INIT_FCALL                                               'str_replace'
         90        SEND_VAR                                                 !1
         91        CONCAT                                           ~66     '%3Cstrong%3E', !1
         92        CONCAT                                           ~67     ~66, '%3C%2Fstrong%3E'
         93        SEND_VAL                                                 ~67
         94        INIT_FCALL                                               'substr'
         95        FETCH_DIM_R                                      ~68     !2, 'content'
         96        SEND_VAL                                                 ~68
         97        SUB                                              ~69     !5, 10
         98        SEND_VAL                                                 ~69
         99        STRLEN                                           ~70     !6
        100        ADD                                              ~71     !5, ~70
        101        ADD                                              ~72     ~71, 10
        102        SEND_VAL                                                 ~72
        103        DO_ICALL                                         $73     
        104        SEND_VAR                                                 $73
        105        DO_ICALL                                         $74     
        106        CONCAT                                           ~75     ~65, $74
        107        CONCAT                                           ~76     ~75, '...%3C%2Fp%3E%0A++++++++++++%3C%2Fdiv%3E'
   51   108        SUB                                              ~77     !5, 0
        109        CONCAT                                           ~78     ~76, ~77
        110        CONCAT                                           ~79     ~78, '+and+'
        111        STRLEN                                           ~80     !6
        112        ADD                                              ~81     ~80, 0
        113        CONCAT                                           ~82     ~79, ~81
        114        CONCAT                                           ~83     ~82, '%0A+++++++++++%3C%2Fli%3E'
        115        ECHO                                                     ~83
   54   116    >   STRLEN                                           ~84     !6
        117        ADD                                              ~85     !5, ~84
        118        ASSIGN                                                   !5, ~85
   34   119      > JMP                                                      ->63
        120    >   FE_FREE                                                  $46
   26   121      > JMP                                                      ->47
        122    >   FE_FREE                                                  $38
   56   123      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.56 ms | 1408 KiB | 21 Q