array_unique
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)
array_unique
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)
array unique php
<?php
// Syntax: array_unique(array $array, int $flags = SORT_STRING): array
// Desc: Removes duplicate values from an array
$arr = Array("red", "red", "green", "blue", "blue", "white");
echo "<pre>";
print_r($arr);
echo "</pre> <br><br>";
$arrUnique = array_unique($arr);
echo "<pre>";
print_r($arrUnique);
echo "</pre> <br><br>";
/* -------- output -----------
Array
(
[0] => red
[1] => red
[2] => green
[3] => blue
[4] => blue
[5] => white
)
Array
(
[0] => red
[2] => green
[3] => blue
[5] => white
)
*/
?>
php count amount of times a value appears in array
$tmp = array_count_values($uid);
$cnt = $tmp[12];
//Or
$cnt = count(array_filter($uid,function($a) {return $a==12;}));
//In both cases $var will be a number
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us