3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AdsListExtractor { private $html = 0; function __construct($a1) { $this->html = $a1; echo $this->html; } function getURLs() { $regexa = '/\<a(.*)\<\/a\>/'; preg_match($regexa, $this->html, $matches); $a = $matches[1]; //echo $a; //echo "\n"; //echo "\n"; //Extract no d'annonces $regexno = '/name="(\d+)"/i'; preg_match($regexno, $a, $matches); //echo 'id:'; //echo $matches[1]; //echo "\n"; //Extract url des fiches $regexurl = '/href="(\S+)"/i'; preg_match($regexurl, $a, $matches); //echo 'url:'; //echo $matches[1]; //echo "\n"; $url_fiche = 'http://www.kijiji.ca' . $matches[1]; echo $url_fiche; //echo "\n"; return $matches; } } class AdInfoExtractor { private $id = 0; function __construct($a1) { $this->id = $a1; } function getHMTL() { $regexatt = '\<table class="ad-attributes">(.*)\<\/table\>'; preg_match($regexatt, $this->id, $matches); $a = $matches[1]; $regexcontent = '/\<div id="UserContent">(.*)\<\/div\>/'; preg_match($regexcontent, $this->id, $matches); $b = $matches[1]; return $a . $b; } } //'http://montreal.kijiji.ca/c-ViewAd?AdId=576130148' $url_liste = "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000"; $html_liste = "<td class=\"description\"><a href=\"/v-autos-camions/ville-de-montreal/2008-bmw-x5-suv/568081363\" class=\"title enable-search-navigation-flag\" name=\"568081363\">2008 BMW X5 SUV</a><p>"; $liste = new AdsListExtractor($html_liste); $ad_info = new AdInfoExtractor($liste->getURLs()[1]); echo $ad_info->getHMTL();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sEYl4
function name:  (null)
number of ops:  19
compiled vars:  !0 = $url_liste, !1 = $html_liste, !2 = $liste, !3 = $ad_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.kijiji.ca%2Fb-autos-camions%2Fgrand-montreal%2Fsuv%2Bvgm-bmw-x5-2001__2009%2Fc174l80002a138a54a1000054a68%3Fsort%3DpriceAsc%26price%3D2000.00__40000.00%26kilometres%3D10000__110000'
   69     1        ASSIGN                                                   !1, '%3Ctd+class%3D%22description%22%3E%3Ca+href%3D%22%2Fv-autos-camions%2Fville-de-montreal%2F2008-bmw-x5-suv%2F568081363%22+class%3D%22title+enable-search-navigation-flag%22+name%3D%22568081363%22%3E2008+BMW+X5+SUV%3C%2Fa%3E%3Cp%3E'
   71     2        NEW                                              $6      'AdsListExtractor'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   72     6        NEW                                              $9      'AdInfoExtractor'
          7        CHECK_FUNC_ARG                                           
          8        INIT_METHOD_CALL                                         !2, 'getURLs'
          9        DO_FCALL                                      0  $10     
         10        SEPARATE                                         $10     $10
         11        FETCH_DIM_FUNC_ARG                               $11     $10, 1
         12        SEND_FUNC_ARG                                            $11
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $9
   74    15        INIT_METHOD_CALL                                         !3, 'getHMTL'
         16        DO_FCALL                                      0  $14     
         17        ECHO                                                     $14
         18      > RETURN                                                   1

Class AdsListExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sEYl4
function name:  __construct
number of ops:  6
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'html'
          2        OP_DATA                                                  !0
    9     3        FETCH_OBJ_R                                      ~2      'html'
          4        ECHO                                                     ~2
   10     5      > RETURN                                                   null

End of function __construct

Function geturls:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sEYl4
function name:  getURLs
number of ops:  27
compiled vars:  !0 = $regexa, !1 = $matches, !2 = $a, !3 = $regexno, !4 = $regexurl, !5 = $url_fiche
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ca%28.%2A%29%5C%3C%5C%2Fa%5C%3E%2F'
   15     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~7      'html'
          4        SEND_VAL                                                 ~7
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
   17     7        FETCH_DIM_R                                      ~9      !1, 1
          8        ASSIGN                                                   !2, ~9
   24     9        ASSIGN                                                   !3, '%2Fname%3D%22%28%5Cd%2B%29%22%2Fi'
   25    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !1
         14        DO_ICALL                                                 
   31    15        ASSIGN                                                   !4, '%2Fhref%3D%22%28%5CS%2B%29%22%2Fi'
   32    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !2
         19        SEND_REF                                                 !1
         20        DO_ICALL                                                 
   36    21        FETCH_DIM_R                                      ~15     !1, 1
         22        CONCAT                                           ~16     'http%3A%2F%2Fwww.kijiji.ca', ~15
         23        ASSIGN                                                   !5, ~16
   37    24        ECHO                                                     !5
   39    25      > RETURN                                                   !1
   40    26*     > RETURN                                                   null

End of function geturls

End of class AdsListExtractor.

Class AdInfoExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sEYl4
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   48     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
   49     3      > RETURN                                                   null

End of function __construct

Function gethmtl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sEYl4
function name:  getHMTL
number of ops:  21
compiled vars:  !0 = $regexatt, !1 = $matches, !2 = $a, !3 = $regexcontent, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ASSIGN                                                   !0, '%5C%3Ctable+class%3D%22ad-attributes%22%3E%28.%2A%29%5C%3C%5C%2Ftable%5C%3E'
   54     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~6      'id'
          4        SEND_VAL                                                 ~6
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
   55     7        FETCH_DIM_R                                      ~8      !1, 1
          8        ASSIGN                                                   !2, ~8
   57     9        ASSIGN                                                   !3, '%2F%5C%3Cdiv+id%3D%22UserContent%22%3E%28.%2A%29%5C%3C%5C%2Fdiv%5C%3E%2F'
   58    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        FETCH_OBJ_R                                      ~11     'id'
         13        SEND_VAL                                                 ~11
         14        SEND_REF                                                 !1
         15        DO_ICALL                                                 
   59    16        FETCH_DIM_R                                      ~13     !1, 1
         17        ASSIGN                                                   !4, ~13
   61    18        CONCAT                                           ~15     !2, !4
         19      > RETURN                                                   ~15
   62    20*     > RETURN                                                   null

End of function gethmtl

End of class AdInfoExtractor.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.35 ms | 1396 KiB | 15 Q