I tried to make an is_Prime() function in PHP. What do you think about this code?
<?php
function is_Prime($x)
{
if($x <= 1)
{
echo $x. " is not a prime number.</br>";
return false;
}
$data = array();
for ($i=1;$i<=$x;$i++)
{
if(is_integer($x/$i))
{
array_push($data, ($x/$i));
}
}
if(count($data)>2)
{
echo $x." is not a prime number</br>";
}
else
{
echo $x. " is a prime number</br>";
}
}
?>
How to use?
for($i=0;$i<=100;$i++)
{
is_Prime($i);
}
isPrime()
oris_prime()
, mixing camelCase and snake_case looks odd – holroy Nov 13 '15 at 3:32