# a more elegant way?

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hello

No doubt there is a better way of expressing this?!

if (\$value > 0 && \$value < 11) {
}
if (\$value > 10 && \$value < 21) {
}
if (\$value > 20 && \$value < 31) {
}
if (\$value > 30 && \$value < 41) {
}
if (\$value > 40 && \$value < 51) {
}
if (\$value > 50 && \$value < 61) {
}
if (\$value > 60 && \$value < 71) {
}
if (\$value > 70 && \$value < 81) {
}
if (\$value > 80 && \$value < 91) {
}
if (\$value > 90 && \$value < 101) {
}
if (\$value > 100 && \$value < 111) {
}
if (\$value > 110 && \$value < 121) {
}

Cheers

Geoff

## Re: a more elegant way?

wrote:

[...]

[...]

if (\$value > 0 && \$value < 121) {
\$section_addressed = floor (\$value / 10);
}

## Re: a more elegant way?

wrote:

Please disregard my previous post -- I hit send a little too quickly, before
reviewing what I'd written.

[...]

if (\$value > 0 && \$value < 121) {
\$section_addressed = floor ((\$value - 1) / 10) + 1;
}

## Re: a more elegant way?

wrote:

Please disregard my previous post; I hit send a bit too quickly, before
reviewing what I'd written.

Yes, there is.

[...]

if (\$value > 0 && \$value < 121) {
\$section_addressed = floor ((\$value - 1) / 10) + 1;
}

## Re: a more elegant way?

On Mon, 30 May 2011 15:03:57 GMT, dougatmilmacdotcom@example.com (Doug
Miller) wrote:

Thanks Doug!

Cheers

Geoff