3v4l.org

run code in 300+ PHP versions simultaneously
<?php $searchq = "cabinet"; $curlPost = 'field-keywords=' . urlencode($searchq) . '&url=index=music&Go=Go'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.amazon.co.uk/exec/obidos/search-handle-form/203-8005778-2511947'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch); curl_close($ch); $rows = explode("\n",$data); foreach($rows as $row) { if(!$row) continue; if(!strstr($row,'href')) continue; if(!strstr($row,'ASIN')) continue; if(!strstr($row,'<b>')) continue; if(strstr($row,'[VINYL]')) continue; if(strstr($row,'[CASSETTE]')) continue; $full_url_row = str_replace('<a href=','http://www.amazon.co.uk',$row); // add the full url $no_bold_tag = str_replace('><b>','#',$full_url_row); // replace the bold tag with # $cdurl = substr($no_bold_tag,0,strpos($no_bold_tag,'#')); $itemdesc = substr($no_bold_tag,strpos($no_bold_tag,'#')+1,strlen($no_bold_tag)); // everything after # is the desc $asin_start = strpos($cdurl,'ASIN/'); // the ASIN appears in the url after ASIN/ $asin = substr($cdurl,$asin_start+5,10); // the ASIN is thankfully always 10 long (we add 5 first to get rid of ASIN/ $strout = "\"$searchq\",\"$asin\",\"$cdurl\",\"$itemdesc\"\n"; // compose the csv string echo "$itemdesc $asin $cdurl\n"; // echo it to the browser, so we can see what's going on }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 154
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 154
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 57
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 64
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 71
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 78
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 84
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 90
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 154
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 154
filename:       /in/Km9OU
function name:  (null)
number of ops:  156
compiled vars:  !0 = $searchq, !1 = $curlPost, !2 = $ch, !3 = $data, !4 = $rows, !5 = $row, !6 = $full_url_row, !7 = $no_bold_tag, !8 = $cdurl, !9 = $itemdesc, !10 = $asin_start, !11 = $asin, !12 = $strout
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'cabinet'
    4     1        INIT_FCALL                                               'urlencode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $14     
          4        CONCAT                                           ~15     'field-keywords%3D', $14
          5        CONCAT                                           ~16     ~15, '%26url%3Dindex%3Dmusic%26Go%3DGo'
          6        ASSIGN                                                   !1, ~16
    6     7        INIT_FCALL_BY_NAME                                       'curl_init'
          8        DO_FCALL                                      0  $18     
          9        ASSIGN                                                   !2, $18
    7    10        INIT_FCALL_BY_NAME                                       'curl_setopt'
         11        SEND_VAR_EX                                              !2
         12        FETCH_CONSTANT                                   ~20     'CURLOPT_URL'
         13        SEND_VAL_EX                                              ~20
         14        SEND_VAL_EX                                              'http%3A%2F%2Fwww.amazon.co.uk%2Fexec%2Fobidos%2Fsearch-handle-form%2F203-8005778-2511947'
         15        DO_FCALL                                      0          
    8    16        INIT_FCALL_BY_NAME                                       'curl_setopt'
         17        SEND_VAR_EX                                              !2
         18        FETCH_CONSTANT                                   ~22     'CURLOPT_HEADER'
         19        SEND_VAL_EX                                              ~22
         20        SEND_VAL_EX                                              1
         21        DO_FCALL                                      0          
    9    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !2
         24        FETCH_CONSTANT                                   ~24     'CURLOPT_RETURNTRANSFER'
         25        SEND_VAL_EX                                              ~24
         26        SEND_VAL_EX                                              1
         27        DO_FCALL                                      0          
   10    28        INIT_FCALL_BY_NAME                                       'curl_setopt'
         29        SEND_VAR_EX                                              !2
         30        FETCH_CONSTANT                                   ~26     'CURLOPT_POST'
         31        SEND_VAL_EX                                              ~26
         32        SEND_VAL_EX                                              1
         33        DO_FCALL                                      0          
   11    34        INIT_FCALL_BY_NAME                                       'curl_setopt'
         35        SEND_VAR_EX                                              !2
         36        FETCH_CONSTANT                                   ~28     'CURLOPT_POSTFIELDS'
         37        SEND_VAL_EX                                              ~28
         38        SEND_VAR_EX                                              !1
         39        DO_FCALL                                      0          
   12    40        INIT_FCALL_BY_NAME                                       'curl_exec'
         41        SEND_VAR_EX                                              !2
         42        DO_FCALL                                      0  $30     
         43        ASSIGN                                                   !3, $30
   13    44        INIT_FCALL_BY_NAME                                       'curl_close'
         45        SEND_VAR_EX                                              !2
         46        DO_FCALL                                      0          
   15    47        INIT_FCALL                                               'explode'
         48        SEND_VAL                                                 '%0A'
         49        SEND_VAR                                                 !3
         50        DO_ICALL                                         $33     
         51        ASSIGN                                                   !4, $33
   18    52      > FE_RESET_R                                       $35     !4, ->154
         53    > > FE_FETCH_R                                               $35, !5, ->154
   21    54    >   BOOL_NOT                                         ~36     !5
         55      > JMPZ                                                     ~36, ->57
         56    > > JMP                                                      ->53
   22    57    >   INIT_FCALL                                               'strstr'
         58        SEND_VAR                                                 !5
         59        SEND_VAL                                                 'href'
         60        DO_ICALL                                         $37     
         61        BOOL_NOT                                         ~38     $37
         62      > JMPZ                                                     ~38, ->64
         63    > > JMP                                                      ->53
   23    64    >   INIT_FCALL                                               'strstr'
         65        SEND_VAR                                                 !5
         66        SEND_VAL                                                 'ASIN'
         67        DO_ICALL                                         $39     
         68        BOOL_NOT                                         ~40     $39
         69      > JMPZ                                                     ~40, ->71
         70    > > JMP                                                      ->53
   24    71    >   INIT_FCALL                                               'strstr'
         72        SEND_VAR                                                 !5
         73        SEND_VAL                                                 '%3Cb%3E'
         74        DO_ICALL                                         $41     
         75        BOOL_NOT                                         ~42     $41
         76      > JMPZ                                                     ~42, ->78
         77    > > JMP                                                      ->53
   25    78    >   INIT_FCALL                                               'strstr'
         79        SEND_VAR                                                 !5
         80        SEND_VAL                                                 '%5BVINYL%5D'
         81        DO_ICALL                                         $43     
         82      > JMPZ                                                     $43, ->84
         83    > > JMP                                                      ->53
   26    84    >   INIT_FCALL                                               'strstr'
         85        SEND_VAR                                                 !5
         86        SEND_VAL                                                 '%5BCASSETTE%5D'
         87        DO_ICALL                                         $44     
         88      > JMPZ                                                     $44, ->90
         89    > > JMP                                                      ->53
   28    90    >   INIT_FCALL                                               'str_replace'
         91        SEND_VAL                                                 '%3Ca+href%3D'
         92        SEND_VAL                                                 'http%3A%2F%2Fwww.amazon.co.uk'
         93        SEND_VAR                                                 !5
         94        DO_ICALL                                         $45     
         95        ASSIGN                                                   !6, $45
   29    96        INIT_FCALL                                               'str_replace'
         97        SEND_VAL                                                 '%3E%3Cb%3E'
         98        SEND_VAL                                                 '%23'
         99        SEND_VAR                                                 !6
        100        DO_ICALL                                         $47     
        101        ASSIGN                                                   !7, $47
   30   102        INIT_FCALL                                               'substr'
        103        SEND_VAR                                                 !7
        104        SEND_VAL                                                 0
        105        INIT_FCALL                                               'strpos'
        106        SEND_VAR                                                 !7
        107        SEND_VAL                                                 '%23'
        108        DO_ICALL                                         $49     
        109        SEND_VAR                                                 $49
        110        DO_ICALL                                         $50     
        111        ASSIGN                                                   !8, $50
   31   112        INIT_FCALL                                               'substr'
        113        SEND_VAR                                                 !7
        114        INIT_FCALL                                               'strpos'
        115        SEND_VAR                                                 !7
        116        SEND_VAL                                                 '%23'
        117        DO_ICALL                                         $52     
        118        ADD                                              ~53     $52, 1
        119        SEND_VAL                                                 ~53
        120        STRLEN                                           ~54     !7
        121        SEND_VAL                                                 ~54
        122        DO_ICALL                                         $55     
        123        ASSIGN                                                   !9, $55
   32   124        INIT_FCALL                                               'strpos'
        125        SEND_VAR                                                 !8
        126        SEND_VAL                                                 'ASIN%2F'
        127        DO_ICALL                                         $57     
        128        ASSIGN                                                   !10, $57
   33   129        INIT_FCALL                                               'substr'
        130        SEND_VAR                                                 !8
        131        ADD                                              ~59     !10, 5
        132        SEND_VAL                                                 ~59
        133        SEND_VAL                                                 10
        134        DO_ICALL                                         $60     
        135        ASSIGN                                                   !11, $60
   34   136        ROPE_INIT                                     9  ~63     '%22'
        137        ROPE_ADD                                      1  ~63     ~63, !0
        138        ROPE_ADD                                      2  ~63     ~63, '%22%2C%22'
        139        ROPE_ADD                                      3  ~63     ~63, !11
        140        ROPE_ADD                                      4  ~63     ~63, '%22%2C%22'
        141        ROPE_ADD                                      5  ~63     ~63, !8
        142        ROPE_ADD                                      6  ~63     ~63, '%22%2C%22'
        143        ROPE_ADD                                      7  ~63     ~63, !9
        144        ROPE_END                                      8  ~62     ~63, '%22%0A'
        145        ASSIGN                                                   !12, ~62
   35   146        ROPE_INIT                                     6  ~70     !9
        147        ROPE_ADD                                      1  ~70     ~70, '+'
        148        ROPE_ADD                                      2  ~70     ~70, !11
        149        ROPE_ADD                                      3  ~70     ~70, '+'
        150        ROPE_ADD                                      4  ~70     ~70, !8
        151        ROPE_END                                      5  ~69     ~70, '%0A'
        152        ECHO                                                     ~69
   18   153      > JMP                                                      ->53
        154    >   FE_FREE                                                  $35
   36   155      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.93 ms | 1408 KiB | 25 Q