3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/"; $string = "<a class=\"hola\" href=\"link1\">Hola qué tal 1</a>"; $string .= "<a class=\'hola\' href=\'link2\'>Hola qué tal 2</a>"; $string .= "<a class=\"hola\" href=\"link3\">Hola qué tal 3</a>"; $string .= "<a class=\"hola\" href=\"link4\">Hola qué tal 4</a>"; $xml = simplexml_load_string($string); $list = $xml->xpath("//@href"); $preparedUrls = array(); foreach($list as $item) { $item = parse_url($item); $preparedUrls[] = $item['scheme'] . '://' . $item['host'] . '/'; } print_r($preparedUrls);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/CWNJE
function name:  (null)
number of ops:  33
compiled vars:  !0 = $pattern, !1 = $string, !2 = $xml, !3 = $list, !4 = $preparedUrls, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%2F%28%3F%3C%3Dhref%3D%28%22%7C%27%29%29%5B%5E%22%27%5D%2B%28%3F%3D%28%22%7C%27%29%29%2F'
    3     1        ASSIGN                                                   !1, '%3Ca+class%3D%22hola%22+href%3D%22link1%22%3EHola+qu%C3%A9+tal+1%3C%2Fa%3E'
    4     2        ASSIGN_OP                                     8          !1, '%3Ca+class%3D%5C%27hola%5C%27+href%3D%5C%27link2%5C%27%3EHola+qu%C3%A9+tal+2%3C%2Fa%3E'
    5     3        ASSIGN_OP                                     8          !1, '%3Ca+class%3D%22hola%22+href%3D%22link3%22%3EHola+qu%C3%A9+tal+3%3C%2Fa%3E'
    6     4        ASSIGN_OP                                     8          !1, '%3Ca+class%3D%22hola%22+href%3D%22link4%22%3EHola+qu%C3%A9+tal+4%3C%2Fa%3E'
    7     5        INIT_FCALL                                               'simplexml_load_string'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !2, $11
    8     9        INIT_METHOD_CALL                                         !2, 'xpath'
         10        SEND_VAL_EX                                              '%2F%2F%40href'
         11        DO_FCALL                                      0  $13     
         12        ASSIGN                                                   !3, $13
   10    13        ASSIGN                                                   !4, <array>
   11    14      > FE_RESET_R                                       $16     !3, ->28
         15    > > FE_FETCH_R                                               $16, !5, ->28
   12    16    >   INIT_FCALL                                               'parse_url'
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $17     
         19        ASSIGN                                                   !5, $17
   13    20        FETCH_DIM_R                                      ~20     !5, 'scheme'
         21        CONCAT                                           ~21     ~20, '%3A%2F%2F'
         22        FETCH_DIM_R                                      ~22     !5, 'host'
         23        CONCAT                                           ~23     ~21, ~22
         24        CONCAT                                           ~24     ~23, '%2F'
         25        ASSIGN_DIM                                               !4
         26        OP_DATA                                                  ~24
   11    27      > JMP                                                      ->15
         28    >   FE_FREE                                                  $16
   15    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
311.84 ms | 1396 KiB | 20 Q