Home »
Imported messages »
comp.lang.php »
a more elegant way?
Re: a more elegant way? [message #174277 is a reply to message #174276] |
Mon, 30 May 2011 15:14 |
geoff
Messages: 8 Registered: April 2011
Karma:
|
Junior Member |
|
|
On Mon, 30 May 2011 15:03:57 GMT, dougatmilmacdotcom(at)example(dot)com (Doug
Miller) wrote:
> In article <0mb7u694aqigfmbdi5ic943mv189ptsh7f(at)4ax(dot)com>, geoff(at)invalid(dot)invalid wrote:
>> Hello
>
> Please disregard my previous post; I hit send a bit too quickly, before
> reviewing what I'd written.
>>
>> No doubt there is a better way of expressing this?!
>
> Yes, there is.
>>
>> Pointers please ...
>>
>> if ($value > 0 && $value < 11) {
>> $section_addressed = '1';
>> }
>> if ($value > 10 && $value < 21) {
>> $section_addressed = '2';
>> }
>> if ($value > 20 && $value < 31) {
>> $section_addressed = '3';
>> }
> [...]
>> if ($value > 110 && $value < 121) {
>> $section_addressed = '12';
>> }
>
> if ($value > 0 && $value < 121) {
> $section_addressed = floor (($value - 1) / 10) + 1;
> }
Thanks Doug!
Cheers
Geoff
|
|
|
Goto Forum:
Current Time: Tue Nov 26 05:25:37 GMT 2024
Total time taken to generate the page: 0.18196 seconds