array_unique
<?php
$fruits_list = array('Orange', 'Apple', ' Banana', 'Cherry', ' Banana');
$result = array_unique($fruits_list);
print_r($result);
?>
Output:
Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry ) function has_dupes($array) {
$dupe_array = array();
foreach ($array as $val) {
if (++$dupe_array[$val] > 1) {
return true;
}
}
return false;
}<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)
Also in PHP:
- check typeof variable php
- base64 php decode with password
- check array is associative laravel
- angular post phph
- convert upper case php
- array splice php
- artisan migrate single class
- create seede for table in laravel
- date formats in php
- date format change in laravel blade
- .catch php
- check if key array php
- adjacent post sort order by post title
- composer remove laravel
- doctrine where
- codeigniter delete record by id
- Str::random
- buddy group hide notice join
- What was the old name of PHP?
- apache php e_warnings e_notice off
- date math sql php
- check if contain keyword php
- check type of object in php
- create custom pagination in laravel 7 for api