FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » a more elegant way?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: a more elegant way? [message #174277 is a reply to message #174276] Mon, 30 May 2011 15:14 Go to previous message
geoff is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: database access
Next Topic: Storing parsed XML-elements as blobs
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 04:32:43 GMT 2024

Total time taken to generate the page: 0.04286 seconds