Helm me with a function
Posted: Fri Nov 04, 2011 8:52 am
I wrote this php code
<?php
echo "<pre>";
$rand=range(1,200);
$arr=array();
print_r($arr);
for($i=0;$i<20;$i++)
{ array_push($arr, array_rand*$rand));
}
print_($arr);
?>
this will print 20 numbers randomly. but now i want to make sure that the random numbers dont repeat themselves. please tell me how to write a function here which will check that the random numbers are not repeating.
please help me
thankyou.
Is this program correct,i wrote a function here to check that the values dont repeat. if its not correct then please help me with the function.
<?php
$rand=range(1,200);
$arr=array();
print_r($arr);
function call()
{
$x=random_nmbers;
if($arr!=$x)
{
array_push;
}
}
for($i=0;$i<20;$i++)
{
array_push($arr, array_rand($rand));
call();
}
echo"<pre>";
sort($arr);
print_r($arr);
?>
<?php
echo "<pre>";
$rand=range(1,200);
$arr=array();
print_r($arr);
for($i=0;$i<20;$i++)
{ array_push($arr, array_rand*$rand));
}
print_($arr);
?>
this will print 20 numbers randomly. but now i want to make sure that the random numbers dont repeat themselves. please tell me how to write a function here which will check that the random numbers are not repeating.
please help me
thankyou.
Is this program correct,i wrote a function here to check that the values dont repeat. if its not correct then please help me with the function.
<?php
$rand=range(1,200);
$arr=array();
print_r($arr);
function call()
{
$x=random_nmbers;
if($arr!=$x)
{
array_push;
}
}
for($i=0;$i<20;$i++)
{
array_push($arr, array_rand($rand));
call();
}
echo"<pre>";
sort($arr);
print_r($arr);
?>