note 106252 deleted from function.rand by danbrown
| From: | danbrown@php.net | Date: | Fri, 21 Oct 2011 15:09:46 +0000 |
| Subject: | note 106252 deleted from function.rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184049@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
According to what Alex Khimch alex wrote at 19-Mar-2011 09:41 his random based image noise generator
will not be random. There was a simple mistake in variable naming. Correct code would be:
<?php
header("Content-type: image/png");
$img = imagecreatetruecolor(500,500);
$ink = imagecolorallocate($img,255,255,255);
for($i=0;$i<500;$i++)
{
for($j=0;$j<500;$j++)
{
imagesetpixel($img, rand(1,500), rand(1,500), $ink);
}
}
imagepng($img);
imagedestroy($img);
?>