I have written a function to check whether any number is prime or not.
Is it okay? or I can better it by any means?
function isPrime($num){
$number = array();
for ($i=2; $i <= $num; $i++){
if(($num%2)==0){
continue;
}
if (($num%$i)==0){
break;
}
$number[]=$i;
}
/*
* how I back calculate to make it successful
foreach ($number as $key => $value) {
echo "$key = $value <br>";
}
echo count($number);
*/
if (count($number)== ($num-2))
{
echo 'it is prime';
}
else {
echo 'not prime';
}
}
isPrime(101112345909);