3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( '#attached' => array ( 'library' => array ( 0 => 'system/base', 1 => 'classy/base', 2 => 'core/normalize', ), 'html_head_link' => array ( 0 => array ( 0 => array ( 'rel' => 'shortcut icon', 'href' => 'http://127.0.0.1/core/misc/favicon.ico', 'type' => 'image/vnd.microsoft.icon', ), ), ), 'html_head' => array ( 0 => array ( 0 => array ( '#tag' => 'meta', '#attributes' => array ( 'charset' => 'utf-8', ), '#weight' => -1000, ), 1 => 'system_meta_content_type', ), 1 => array ( 0 => array ( '#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array ( 'name' => 'Generator', 'content' => 'Drupal 8 (https://www.drupal.org)', ), ), 1 => 'system_meta_generator', ), 2 => array ( 0 => array ( '#tag' => 'meta', '#attributes' => array ( 'name' => 'MobileOptimized', 'content' => 'width', ), ), 1 => 'MobileOptimized', ), 3 => array ( 0 => array ( '#tag' => 'meta', '#attributes' => array ( 'name' => 'HandheldFriendly', 'content' => 'true', ), ), 1 => 'HandheldFriendly', ), 4 => array ( 0 => array ( '#tag' => 'meta', '#attributes' => array ( 'name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0', ), ), 1 => 'viewport', ), ), ), ); $merge = array ( 'html_head' => array ( 0 => array ( 0 => array ( '#tag' => 'link', '#attributes' => array ( 'rel' => 'shortcut icon', 'href' => 'http://127.0.0.1/core/misc/favicon.ico', 'type' => 'image/vnd.microsoft.icon', ), ), 1 => 'html_head_link:shortcut icon:http://127.0.0.1/core/misc/favicon.ico', ), ) ); function system_module_test_page_attachments_alter(&$page) { // Remove the HTML5 mobile meta-tags. $meta_tags_to_remove = ['MobileOptimized', 'HandheldFriendly', 'viewport', 'cleartype']; foreach ($page['#attached']['html_head'] as $index => $parts) { if (in_array($parts[1], $meta_tags_to_remove)) { unset($page['#attached']['html_head'][$index]); } } } function processHtmlHead(array $html_head) { $head = []; foreach ($html_head as $index => $item) { list($data, $key) = $item; if (!isset($data['#type'])) { $data['#type'] = 'html_tag'; } $head[$key] = $data; } return $head; } system_module_test_page_attachments_alter($array); $attached = &$array['#attached']; $attached = array_merge_recursive($attached, $merge); $head = processHtmlHead($attached['html_head']); print_r($head);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/clIdV
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array, !1 = $merge, !2 = $attached, !3 = $head
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   96     1        ASSIGN                                                   !1, <array>
  139     2        INIT_FCALL                                               'system_module_test_page_attachments_alter'
          3        SEND_REF                                                 !0
          4        DO_FCALL                                      0          
  141     5        FETCH_DIM_W                                      $7      !0, '%23attached'
          6        ASSIGN_REF                                               !2, $7
  143     7        INIT_FCALL                                               'array_merge_recursive'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !2, $9
  145    12        INIT_FCALL                                               'processhtmlhead'
         13        FETCH_DIM_R                                      ~11     !2, 'html_head'
         14        SEND_VAL                                                 ~11
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !3, $12
  147    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function system_module_test_page_attachments_alter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/clIdV
function name:  system_module_test_page_attachments_alter
number of ops:  19
compiled vars:  !0 = $page, !1 = $meta_tags_to_remove, !2 = $parts, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  116     0  E >   RECV                                             !0      
  118     1        ASSIGN                                                   !1, <array>
  119     2        FETCH_DIM_R                                      ~5      !0, '%23attached'
          3        FETCH_DIM_R                                      ~6      ~5, 'html_head'
          4      > FE_RESET_R                                       $7      ~6, ->17
          5    > > FE_FETCH_R                                       ~8      $7, !2, ->17
          6    >   ASSIGN                                                   !3, ~8
  120     7        INIT_FCALL                                               'in_array'
          8        FETCH_DIM_R                                      ~10     !2, 1
          9        SEND_VAL                                                 ~10
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $11     
         12      > JMPZ                                                     $11, ->16
  121    13    >   FETCH_DIM_UNSET                                  $12     !0, '%23attached'
         14        FETCH_DIM_UNSET                                  $13     $12, 'html_head'
         15        UNSET_DIM                                                $13, !3
  119    16    > > JMP                                                      ->5
         17    >   FE_FREE                                                  $7
  124    18      > RETURN                                                   null

End of function system_module_test_page_attachments_alter

Function processhtmlhead:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/clIdV
function name:  processHtmlHead
number of ops:  22
compiled vars:  !0 = $html_head, !1 = $head, !2 = $item, !3 = $index, !4 = $data, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  126     0  E >   RECV                                             !0      
  127     1        ASSIGN                                                   !1, <array>
  128     2      > FE_RESET_R                                       $7      !0, ->19
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->19
          4    >   ASSIGN                                                   !3, ~8
  129     5        QM_ASSIGN                                        ~10     !2
          6        FETCH_LIST_R                                     $11     ~10, 0
          7        ASSIGN                                                   !4, $11
          8        FETCH_LIST_R                                     $13     ~10, 1
          9        ASSIGN                                                   !5, $13
         10        FREE                                                     ~10
  130    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !4, '%23type'
         12        BOOL_NOT                                         ~16     ~15
         13      > JMPZ                                                     ~16, ->16
  131    14    >   ASSIGN_DIM                                               !4, '%23type'
         15        OP_DATA                                                  'html_tag'
  133    16    >   ASSIGN_DIM                                               !1, !5
         17        OP_DATA                                                  !4
  128    18      > JMP                                                      ->3
         19    >   FE_FREE                                                  $7
  135    20      > RETURN                                                   !1
  136    21*     > RETURN                                                   null

End of function processhtmlhead

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.54 ms | 1402 KiB | 21 Q