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', ), ), ), ); 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; } function processHtmlHeadLink(array $html_head_link) { $attached = []; foreach ($html_head_link as $item) { $attributes = $item[0]; $should_add_header = isset($item[1]) ? $item[1] : FALSE; $element = array( '#tag' => 'link', '#attributes' => $attributes, ); $href = $attributes['href']; $attached['html_head'][] = [$element, 'html_head_link:' . $attributes['rel'] . ':' . $href]; if ($should_add_header) { // Also add a HTTP header "Link:". $href = '<' . Html::escape($attributes['href'] . '>'); unset($attributes['href']); $attached['http_header'][] = ['Link', $href . drupal_http_header_attributes($attributes), TRUE]; } } return $attached; } system_module_test_page_attachments_alter($array); $attached = $array['#attached']; $attached = array_merge_recursive($attached, processHtmlHeadLink($attached['html_head_link'])); $head = processHtmlHead($attached['html_head']); print_r($head);
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Array ( [system_meta_content_type] => Array ( [#tag] => meta [#attributes] => Array ( [charset] => utf-8 ) [#weight] => -1000 [#type] => html_tag ) [system_meta_generator] => Array ( [#type] => html_tag [#tag] => meta [#attributes] => Array ( [name] => Generator [content] => Drupal 8 (https://www.drupal.org) ) ) [html_head_link:shortcut icon:http://127.0.0.1/core/misc/favicon.ico] => Array ( [#tag] => link [#attributes] => Array ( [rel] => shortcut icon [href] => http://127.0.0.1/core/misc/favicon.ico [type] => image/vnd.microsoft.icon ) [#type] => html_tag ) )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Array ( [system_meta_content_type] => Array ( [#tag] => meta [#attributes] => Array ( [charset] => utf-8 ) [#weight] => -1000 [#type] => html_tag ) [system_meta_generator] => Array ( [#type] => html_tag [#tag] => meta [#attributes] => Array ( [name] => Generator [content] => Drupal 8 (https://www.drupal.org) ) ) [html_head_link:shortcut icon:http://127.0.0.1/core/misc/favicon.ico] => Array ( [#tag] => link [#attributes] => Array ( [rel] => shortcut icon [href] => http://127.0.0.1/core/misc/favicon.ico [type] => image/vnd.microsoft.icon ) [#type] => html_tag ) )

preferences:
218.02 ms | 404 KiB | 227 Q