3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ThreePointStudio_CustomMarkupForUser_Constants { public static $availableMarkups = array( // Text Effects "bold" => array( "format" => array( array("span", array("style" => array("font-weight" => array("bold")))) ), ), "italic" => array( "format" => array( array("span", array("style" => array("font-style" => array("italic")))) ), ), "underline" => array( "format" => array( array("span", array("style" => array("text-decoration" => array("underline"))), array('mergeProperties' => true)) ), ), "overline" => array( "format" => array( array("span", array("style" => array("text-decoration" => array("overline"))), array('mergeProperties' => true)) ), ), "strike" => array( "format" => array( array("span", array("style" => array("text-decoration" => array("line-through"))), array('mergeProperties' => true)) ), ), "text_colour" => array( "format" => array( array("span", array("style" => array("color" => array("{_value}"))), array("variableFeed" => array("_value"))) ), ), "font_face" => array( "format" => array( array("span", array("style" => array("font-family" => array("{fontFamily}"))), array("variableFeed" => array("fontFamily"))) ), ), // Background and Borders "background_colour" => array( "format" => array( array("span", array("style" => array("background-color" => array("{_value}"))), array("variableFeed" => array("_value"))) ), ), "border" => array( "format" => array( array("span", array("class" => array("borderText"))) ), ), "border_colour" => array( "format" => array( array("span", array("style" => array("border-color" => array("{_value}"))), array("variableFeed" => array("_value"))) ), ), "border_style" => array( "format" => array( array("span", array("style" => array("border-style" => array("{borderStyle}"))), array("variableFeed" => array("borderStyle"))) ), ), ); public static $borderList = array( 0 => "none", 1 => "dotted", 2 => "dashed", 3 => "solid", 4 => "double", 5 => "groove", 6 => "ridge", 7 => "inset", 8 => "outset" ); // Mostly copied from http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html public static $fontList = array( 0 => array("name" => "", "fullname" => "inherit"), 1 => array("name" => "Arial", "fullname" => 'Arial, Helvetica, sans-serif'), 2 => array("name" => "Arial Black", "fullname" => "'Arial Black', Gadget, sans-serif"), 3 => array("name" => "Comic Sans MS", "fullname" => "'Comic Sans MS', cursive, sans-serif"), 4 => array("name" => "Courier New", "fullname" => "'Courier New', Courier, monospace"), 5 => array("name" => "Georgia", "fullname" => 'Georgia, serif'), 6 => array("name" => "Impact", "fullname" => 'Impact, Charcoal, sans-serif'), 7 => array("name" => "Lucida Console", "fullname" => "'Lucida Console', Monaco, monospace"), 8 => array("name" => "Lucida Sans Unicode", "fullname" => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif"), 9 => array("name" => "Palatino Linotype", "fullname" => "'Palatino Linotype', 'Book Antiqua', Palatino, serif"), 10 => array("name" => "Tahoma", "fullname" => 'Tahoma, Geneva, sans-serif'), 11 => array("name" => "Times New Roman", "fullname" => "'Times New Roman', Times, serif"), 12 => array("name" => "Trebuchet MS", "fullname" => "'Trebuchet MS', Helvetica, sans-serif"), 13 => array("name" => "Verdana", "fullname" => 'Verdana, Geneva, sans-serif'), ); public static $defaultOptionsArray = array( "username" => array(), "usertitle" => array() ); } $options = unserialize('a:2:{s:8:"username";a:9:{s:4:"bold";i:1;s:6:"italic";i:1;s:9:"underline";i:1;s:11:"text_colour";s:7:"#e01be0";s:9:"font_face";i:13;s:17:"background_colour";s:7:"#4683ab";s:6:"border";i:1;s:13:"border_colour";s:7:"#d91fd9";s:12:"border_style";i:1;}s:9:"usertitle";a:6:{s:4:"bold";i:1;s:6:"italic";i:1;s:9:"underline";i:1;s:6:"strike";i:1;s:8:"overline";i:1;s:9:"font_face";i:3;}}'); $sortedTags = $firstOccurrence = array(); foreach ($options["username"] as $optionName => $optionValue) { end($sortedTags); foreach (ThreePointStudio_CustomMarkupForUser_Constants::$availableMarkups[$optionName]["format"] as $tag) { $sortedTags[] = $tag; end($sortedTags); $index = key($sortedTags); $theTag = &$sortedTags[$index]; if (!in_array($theTag[0], $firstOccurrence)) { $firstOccurrence[$theTag[0]] = $index; } else { // Try to see if we can merge the properties if (isset($theTag[2]["loneTag"]) && $theTag[2]["loneTag"]) { // It wants it own tag continue; } $firstOccurrenceTag = &$sortedTags[$firstOccurrence[$theTag[0]]]; $intersection = array_keys(array_intersect_key($theTag[1], $firstOccurrenceTag[1])); if (in_array("style", $intersection)) { if ((isset($theTag[2]["mergeProperties"]) && $theTag[2]["mergeProperties"]) && (isset($firstOccurrenceTag[2]["mergeProperties"]) && $firstOccurrenceTag[2]["mergeProperties"])) { $firstOccurrenceTag[1]["style"] = array_replace_recursive($firstOccurrenceTag[1]["style"], $theTag[1]["style"]); } else { $firstOccurrenceTag[1]["style"] = array_replace($firstOccurrenceTag[1]["style"], $theTag[1]["style"]); } unset($theTag[1]["style"]); } if (in_array("class", $intersection)) { $firstOccurrenceTag[1]["class"] = array_replace($firstOccurrenceTag[1]["class"], $theTag[1]["class"]); unset($theTag[1]["class"]); } // Try to put anything that is not in the first occurrence tag into the first occurrence tag instead foreach ($theTag[1] as $attr => $attrValue) { if (!in_array($attr, array_keys($firstOccurrenceTag[1]))) { $firstOccurrenceTag[1][$attr] = $attrValue; unset($theTag[1][$attr]); } } if (empty($theTag[1])) { // No attr, drop the tag unset($sortedTags[$index]); end($sortedTags); continue; } // What is left is conflicted attributes. Leave as is in its own tag. } } } var_dump($sortedTags);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(9) { [0]=> array(2) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["font-weight"]=> array(1) { [0]=> string(4) "bold" } } } } [1]=> array(2) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["font-style"]=> array(1) { [0]=> string(6) "italic" } } } } [2]=> array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["text-decoration"]=> array(1) { [0]=> string(9) "underline" } } } [2]=> array(1) { ["mergeProperties"]=> bool(true) } } [3]=> array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["color"]=> array(1) { [0]=> string(8) "{_value}" } } } [2]=> array(1) { ["variableFeed"]=> array(1) { [0]=> string(6) "_value" } } } [4]=> array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["font-family"]=> array(1) { [0]=> string(12) "{fontFamily}" } } } [2]=> array(1) { ["variableFeed"]=> array(1) { [0]=> string(10) "fontFamily" } } } [5]=> array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["background-color"]=> array(1) { [0]=> string(8) "{_value}" } } } [2]=> array(1) { ["variableFeed"]=> array(1) { [0]=> string(6) "_value" } } } [6]=> array(2) { [0]=> string(4) "span" [1]=> array(1) { ["class"]=> array(1) { [0]=> string(10) "borderText" } } } [7]=> array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["border-color"]=> array(1) { [0]=> string(8) "{_value}" } } } [2]=> array(1) { ["variableFeed"]=> array(1) { [0]=> string(6) "_value" } } } [8]=> &array(3) { [0]=> string(4) "span" [1]=> array(1) { ["style"]=> array(1) { ["border-style"]=> array(1) { [0]=> string(13) "{borderStyle}" } } } [2]=> array(1) { ["variableFeed"]=> array(1) { [0]=> string(11) "borderStyle" } } } }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
array(1) { [0]=> &array(2) { [0]=> string(4) "span" [1]=> array(2) { ["style"]=> array(8) { ["font-weight"]=> array(1) { [0]=> string(4) "bold" } ["font-style"]=> array(1) { [0]=> string(6) "italic" } ["text-decoration"]=> array(1) { [0]=> string(9) "underline" } ["color"]=> array(1) { [0]=> string(8) "{_value}" } ["font-family"]=> array(1) { [0]=> string(12) "{fontFamily}" } ["background-color"]=> array(1) { [0]=> string(8) "{_value}" } ["border-color"]=> array(1) { [0]=> string(8) "{_value}" } ["border-style"]=> array(1) { [0]=> string(13) "{borderStyle}" } } ["class"]=> array(1) { [0]=> string(10) "borderText" } } } }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Fatal error: Call to undefined function array_replace() in /in/dtcv7 on line 126
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function array_intersect_key() in /in/dtcv7 on line 120
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/dtcv7 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/dtcv7 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/dtcv7 on line 5
Process exited with code 255.

preferences:
248.86 ms | 401 KiB | 313 Q