3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DAL { function getNoAnnonces() { return array( "12334", "233455" ); } function getURLRecherches() { //$line = "Nissan, Rogue, 2008, 1000, 9000, 10000, 110000"; //$line2 = "Nissan, Rogue, 2009, 1000, 9000, 10000, 90000"; return array( "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-nissan-rogue-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000", "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" //split(",", $line, 7), //split(",", $line2, 7) ); } } 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 $url = 0; private $html = ''; function __construct($a1) { $this->url = $a1; } function getHMTL() { $regexatt = '/\<table class="ad-attributes">(.*)\<\/table\>/'; preg_match($regexatt, $this->url, $matches); $a = $matches[1]; $regexcontent = '/\<div id="UserContent">(.*)\<\/div\>/'; preg_match($regexcontent, $this->url, $matches); $b = $matches[1]; return $a[0] . $b[0]; } } //'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_test = "<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>"; //$html_liste = file_get_contents($url_liste); $liste = new AdsListExtractor($html_test); $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/ZA9jg
function name:  (null)
number of ops:  19
compiled vars:  !0 = $url_liste, !1 = $html_test, !2 = $liste, !3 = $ad_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     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'
   93     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'
   97     2        NEW                                              $6      'AdsListExtractor'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   98     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
  100    15        INIT_METHOD_CALL                                         !3, 'getHMTL'
         16        DO_FCALL                                      0  $14     
         17        ECHO                                                     $14
         18      > RETURN                                                   1

Class DAL:
Function getnoannonces:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZA9jg
function name:  getNoAnnonces
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   <array>
   11     1*     > RETURN                                                   null

End of function getnoannonces

Function geturlrecherches:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZA9jg
function name:  getURLRecherches
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   <array>
   23     1*     > RETURN                                                   null

End of function geturlrecherches

End of class DAL.

Class AdsListExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZA9jg
function name:  __construct
number of ops:  6
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        ASSIGN_OBJ                                               'html'
          2        OP_DATA                                                  !0
   32     3        FETCH_OBJ_R                                      ~2      'html'
          4        ECHO                                                     ~2
   33     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/ZA9jg
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
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ca%28.%2A%29%5C%3C%5C%2Fa%5C%3E%2F'
   38     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                                                 
   40     7        FETCH_DIM_R                                      ~9      !1, 1
          8        ASSIGN                                                   !2, ~9
   47     9        ASSIGN                                                   !3, '%2Fname%3D%22%28%5Cd%2B%29%22%2Fi'
   48    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !1
         14        DO_ICALL                                                 
   54    15        ASSIGN                                                   !4, '%2Fhref%3D%22%28%5CS%2B%29%22%2Fi'
   55    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !2
         19        SEND_REF                                                 !1
         20        DO_ICALL                                                 
   59    21        FETCH_DIM_R                                      ~15     !1, 1
         22        CONCAT                                           ~16     'http%3A%2F%2Fwww.kijiji.ca', ~15
         23        ASSIGN                                                   !5, ~16
   60    24        ECHO                                                     !5
   62    25      > RETURN                                                   !1
   63    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/ZA9jg
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
   72     1        ASSIGN_OBJ                                               'url'
          2        OP_DATA                                                  !0
   73     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/ZA9jg
function name:  getHMTL
number of ops:  23
compiled vars:  !0 = $regexatt, !1 = $matches, !2 = $a, !3 = $regexcontent, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ctable+class%3D%22ad-attributes%22%3E%28.%2A%29%5C%3C%5C%2Ftable%5C%3E%2F'
   78     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~6      'url'
          4        SEND_VAL                                                 ~6
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
   79     7        FETCH_DIM_R                                      ~8      !1, 1
          8        ASSIGN                                                   !2, ~8
   81     9        ASSIGN                                                   !3, '%2F%5C%3Cdiv+id%3D%22UserContent%22%3E%28.%2A%29%5C%3C%5C%2Fdiv%5C%3E%2F'
   82    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        FETCH_OBJ_R                                      ~11     'url'
         13        SEND_VAL                                                 ~11
         14        SEND_REF                                                 !1
         15        DO_ICALL                                                 
   83    16        FETCH_DIM_R                                      ~13     !1, 1
         17        ASSIGN                                                   !4, ~13
   85    18        FETCH_DIM_R                                      ~15     !2, 0
         19        FETCH_DIM_R                                      ~16     !4, 0
         20        CONCAT                                           ~17     ~15, ~16
         21      > RETURN                                                   ~17
   86    22*     > RETURN                                                   null

End of function gethmtl

End of class AdInfoExtractor.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.43 ms | 1396 KiB | 15 Q