Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1938

Re: a more elegant way?

From dougatmilmacdotcom@example.com (Doug Miller)
Newsgroups comp.lang.php
Subject Re: a more elegant way?
Date 2011-05-30 15:03 +0000
Organization A noiseless patient Spider
Message-ID <is0bl4$iu3$2@dont-email.me> (permalink)
References <0mb7u694aqigfmbdi5ic943mv189ptsh7f@4ax.com>

Show all headers | View raw


In article <0mb7u694aqigfmbdi5ic943mv189ptsh7f@4ax.com>, geoff@invalid.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;
}

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

a more elegant way? geoff@invalid.invalid - 2011-05-30 15:52 +0100
  Re: a more elegant way? dougatmilmacdotcom@example.com (Doug Miller) - 2011-05-30 15:03 +0000
    Re: a more elegant way? geoff@invalid.invalid - 2011-05-30 16:14 +0100

csiph-web