array second occurence php code example
Example 1: 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
Example 2: program logic for second largest number in an array in php
function secondHighest(array $arr) {
sort($arr);
echo $arr[sizeof($arr)-2];
}
secondHighest(array( 4, 9, 5, 2, 8, 0, 3, 22));