3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<DATA <div class="list"> <div class="ui_checkbox type hidden" data-categories="57 48 "> <input id="attraction_type_119" type="checkbox" value="119" <label for="attraction_type_119">Aquariums</label> </div> <div class="ui_checkbox type " data-categories="47 "> <input id="attraction_type_120" type="checkbox" value="120" <label for="attraction_type_120">Arènes et stades</label> </div> </div> DATA; $data = array(); $dom = new DOMDocument(); @$dom->loadHTML($html); $xp = new DOMXpath($dom); $items = $xp->query('//div[@class="list"]/div'); foreach($items as $item) { $temp["data_categorie"] = $item->getAttribute("data-categories"); foreach ($item->childNodes as $child) { if ($child->nodeName === "input") { $temp["input_value"] = $child->getAttribute("value"); $temp["label_text"] = $child->nextSibling->nodeValue; } } $data[] = $temp; } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 45
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 45
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 41
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 40
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 41
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/6ieof
function name:  (null)
number of ops:  50
compiled vars:  !0 = $html, !1 = $data, !2 = $dom, !3 = $xp, !4 = $items, !5 = $item, !6 = $temp, !7 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+class%3D%22list%22%3E%0A++++%3Cdiv+class%3D%22ui_checkbox+type+hidden%22+data-categories%3D%2257+48+%22%3E%0A++++++++%3Cinput+id%3D%22attraction_type_119%22+type%3D%22checkbox%22+value%3D%22119%22%0A++++++++%3Clabel+for%3D%22attraction_type_119%22%3EAquariums%3C%2Flabel%3E%0A++++%3C%2Fdiv%3E%0A++++%3Cdiv+class%3D%22ui_checkbox+type+%22+data-categories%3D%2247+%22%3E%0A++++++++%3Cinput+id%3D%22attraction_type_120%22+type%3D%22checkbox%22+value%3D%22120%22%0A++++++++%3Clabel+for%3D%22attraction_type_120%22%3EAr%C3%A8nes+et+stades%3C%2Flabel%3E%0A++++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
   16     1        ASSIGN                                                   !1, <array>
   17     2        NEW                                              $10     'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $10
   18     5        BEGIN_SILENCE                                    ~13     
          6        INIT_METHOD_CALL                                         !2, 'loadHTML'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        END_SILENCE                                              ~13
   19    10        NEW                                              $15     'DOMXpath'
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !3, $15
   20    14        INIT_METHOD_CALL                                         !3, 'query'
         15        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%22list%22%5D%2Fdiv'
         16        DO_FCALL                                      0  $18     
         17        ASSIGN                                                   !4, $18
   21    18      > FE_RESET_R                                       $20     !4, ->45
         19    > > FE_FETCH_R                                               $20, !5, ->45
   22    20    >   INIT_METHOD_CALL                                         !5, 'getAttribute'
         21        SEND_VAL_EX                                              'data-categories'
         22        DO_FCALL                                      0  $22     
         23        ASSIGN_DIM                                               !6, 'data_categorie'
         24        OP_DATA                                                  $22
   23    25        FETCH_OBJ_R                                      ~23     !5, 'childNodes'
         26      > FE_RESET_R                                       $24     ~23, ->41
         27    > > FE_FETCH_R                                               $24, !7, ->41
   24    28    >   FETCH_OBJ_R                                      ~25     !7, 'nodeName'
         29        IS_IDENTICAL                                             ~25, 'input'
         30      > JMPZ                                                     ~26, ->40
   25    31    >   INIT_METHOD_CALL                                         !7, 'getAttribute'
         32        SEND_VAL_EX                                              'value'
         33        DO_FCALL                                      0  $28     
         34        ASSIGN_DIM                                               !6, 'input_value'
         35        OP_DATA                                                  $28
   26    36        FETCH_OBJ_R                                      ~30     !7, 'nextSibling'
         37        FETCH_OBJ_R                                      ~31     ~30, 'nodeValue'
         38        ASSIGN_DIM                                               !6, 'label_text'
         39        OP_DATA                                                  ~31
   23    40    > > JMP                                                      ->27
         41    >   FE_FREE                                                  $24
   29    42        ASSIGN_DIM                                               !1
         43        OP_DATA                                                  !6
   21    44      > JMP                                                      ->19
         45    >   FE_FREE                                                  $20
   32    46        INIT_FCALL                                               'print_r'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.3 ms | 1437 KiB | 14 Q