-2
$highest = max($data);
$check = array();
$resultype = array();
foreach($data as $key => $value){
if($value === $highest){
echo $key;

//output (t1,t3);

$check = $key;
}
}

echo $check; 

//ouput(t3);

Why is it working when I store the $key into a array ?
When I echo in $key in foreach I get what I want (t1,t3) but when I store into and array and output it out side foreach, it only give me (t3).
How do I fix this and store $key into a array with the result I wanted?

hg8
  • 1,082
  • 2
  • 15
  • 28
user3233074
  • 519
  • 4
  • 18

1 Answers1

0

You're not storing $key in the array, you're assigning it to the variable $check.

Try using $check[] = $key;.

Jordi Vermeulen
  • 1,168
  • 1
  • 10
  • 17