Re: round a number down to an odd number
| From: | Ignacio Vazquez-Abrams | Date: | Sun, 10 Dec 2000 20:06:04 +0000 |
| Subject: | Re: round a number down to an odd number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29582@lists.php.net to get a copy of this message | ||
On Sun, 10 Dec 2000, Tom Beidler wrote:
> I have a page where I'm trying to swap out images to represent a product.
> There's one image for every 2 products id's. Is there a way in PHP to return
> an odd number? That way I can name the images after the odd part numbers, if
> someone orders the small size which would have the even part number, I could
> have the formula knock off a number, and use the odd part number image. If
> they would order the large the formula wouldn't knock off a number.
>
> >>.>>.>>>.>>>>>.>>>>>>>>>
> Tom Beidler
> Orbit Tech Services
> 805.455.7119 (cell)
> 805.682.8972 (phone)
> 805.682.5833 (fax)
> tbeidler@mindspring.com
> >>.>>.>>>.>>>>>.>>>>>>>>>
>
Simple math:
$i=rand(0,9);
$i=$i*2+1;
$i will be an odd random number between 1 and 19.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>