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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.98 ms | 1408 KiB | 21 Q