1
Guys I’m with a problem, the comparison is not working, He should return the message "All right" but ends up returning only the message "Valid only numbers 1 a 60"
<?php
$a = array(1,2,3,4,60);
$b = count($a);
$u = count(array_unique($a));
echo "Original: ".$b."<br>"."Unicos: ".$u."<br>";
if($b === $u){
foreach($a as $aceitos){
if($aceitos > 0 AND $aceitos < 61) {
echo "Validos apenas números de 1 a 60";
}else{
echo "Tudo certo";
}
}
echo "Arrays iguais";
}else{
echo "Arrays diferentes";
}
?>
I really got confused, but it was because I’ve made several changes and nothing works, now for example, even if I fix the comparison if I put "0" in the array it does not identify as an error, it displays the message "all right" and if I put a value "60" in the array it works right, my problem now is about the "0"
– Otavio Fagundes
then you need to use
$aceitos < 1
that it will identify the zero as error.– relaxeaza
I updated the answer.
– relaxeaza
It cannot be less than 1 E greater than 60 at the same time, it is correct to use less than 1 OU greater than 60
– Jader A. Wagner
Well posted @Jadera.Wagner, hadn’t even noticed. Updated.
– relaxeaza