Answers for "how to avoid duplicate code in php"

PHP
1

how to remove duplicate values from an array in php

<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>

Array
(
    [a] => green
    [0] => red
    [1] => blue
)
Posted by: Guest on January-13-2021
-1

php remove duplicates from string

$str = implode(',',array_unique(explode(',', $str)));
Posted by: Guest on June-24-2020

Code answers related to "how to avoid duplicate code in php"

Browse Popular Code Answers by Language