diff --git a/core/polyfills.php b/core/polyfills.php index 365e9ddb..b4177c02 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -3,35 +3,6 @@ * Things which should be in the core API * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** - * Remove an item from an array - */ -function array_remove(array $array, $to_remove): array -{ - $array = array_unique($array); - $a2 = []; - foreach ($array as $existing) { - if ($existing != $to_remove) { - $a2[] = $existing; - } - } - return $a2; -} - -/** - * Adds an item to an array. - * - * Also removes duplicate values from the array. - */ -function array_add(array $array, $element): array -{ - // Could we just use array_push() ? - // http://www.php.net/manual/en/function.array-push.php - $array[] = $element; - $array = array_unique($array); - return $array; -} - /** * Return the unique elements of an array, case insensitively */ diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php index b0af98bd..6f771871 100644 --- a/ext/tag_list/theme.php +++ b/ext/tag_list/theme.php @@ -227,7 +227,7 @@ class TagListTheme extends Themelet $display_html = ''; $tag = $row['tag']; $h_tag = html_escape($tag); - + $tag_category_css = ''; $tag_category_style = ''; $h_tag_split = explode(':', html_escape($tag), 2); @@ -277,8 +277,7 @@ class TagListTheme extends Themelet if (!in_array($tag, $tags) && !in_array("-$tag", $tags)) { return ""; } else { - $tags = array_remove($tags, $tag); - $tags = array_remove($tags, "-$tag"); + $tags = array_diff($tags, [$tag, "-$tag"]); return "R"; } } @@ -288,8 +287,7 @@ class TagListTheme extends Themelet if (in_array($tag, $tags)) { return ""; } else { - $tags = array_remove($tags, "-$tag"); - $tags = array_add($tags, $tag); + $tags = array_diff($tags, ["-$tag"]) + [$tag]; return "A"; } } @@ -299,8 +297,7 @@ class TagListTheme extends Themelet if (in_array("-$tag", $tags)) { return ""; } else { - $tags = array_remove($tags, $tag); - $tags = array_add($tags, "-$tag"); + $tags = array_diff($tags, [$tag]) + ["-$tag"]; return "S"; } }