<br>I'm not took concerned about readability. I already code in the style of spaghetti, so cleanliness is not my first concern. I think I might break the switch into chunks of 20, and then use a single if statement to determine which switch to compare the variable against.<br>
<br>Thanks for the replies though.<br><br>Bob, I know not of this 'C' you language speak of... unless you forgot to add the '#' after it ;)<br><br>-Rob<br><br><div class="gmail_quote">On Thu, Feb 21, 2008 at 1:11 PM, Robert Meyer <<a href="mailto:meyer_rm@yahoo.com">meyer_rm@yahoo.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Well, if you write the code in C, just create an array of addresses of arrays and just directly access the array by position. Then you don't even need any comparisons. :-)<br>
<br>Cheers!<br><br>Bob<br><div> </div>--<br>"When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return."<br>
--Leonardo da Vinci<div><div></div><div class="Wj3C7c"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
----- Original Message ----<br>From: Franklin Kumro Jr <<a href="mailto:fkumro@gmail.com" target="_blank">fkumro@gmail.com</a>><br>To: <a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br>Sent: Thursday, February 21, 2008 12:18:07 PM<br>
Subject: Re: [nflug] PHP (switch vs. nested if)<br><br>
I
would
agree
that
a
switch
statement
would
be
the
preferred
method. <br>Multiple
nested
if
statements
hurt
code
readability,
let
alone
a
1-80 <br>range.<br><br>-Frank<br>On
Feb
21,
2008,
at
11:43
AM,
Timothy
Finucane
wrote:<br><br>>
A
switch
is
the
most
efficient
method.
I'm
not
sure
how
much
speed <br>>
performance
is
affected,
but
nested
ifs
would
make
the
code <br>>
difficult
to
read.<br>><br>>
-- <br>>
Timothy
J.
Finucane<br>><br>>
<a href="http://www.speljamr.com" target="_blank">http://www.speljamr.com</a><br>><br>>
Facebook:
<a href="http://www.facebook.com/p/Timothy_J_Finucane/682422189" target="_blank">http://www.facebook.com/p/Timothy_J_Finucane/682422189</a><br>><br>><br>><br>>
On
2/21/08,
Rob
Dege
<<a href="mailto:livemotion@gmail.com" target="_blank">livemotion@gmail.com</a>>
wrote:<br>>
Hi,
I'm
wondering
which
would
provide
faster
processing
time
based <br>>
on
the
web
page
I'm
building.<br>><br>>
I
have
a
variable,
let's
call
it
$num.
$num
is
an
int
that
can
be <br>>
anywhere
from
1
to
80.
Based
on
$num's
value,
an
array
is
assigned <br>>
that
is
then
used
on
the
web
page.
Since
this
is
for
a
web
page,
I <br>>
want
to
minimize
the
wait
time
as
much
as
possible,
and
I'm
guessing <br>>
that
this
could
be
a
potential
bottleneck.
I
have
not
written
the <br>>
code
yet,
so
I
can't
compare
load
times.
I'm
considering
this
more <br>>
of
a
"do
it
the
preferred
way
the
first
time".<br>><br>>
So
I'm
curious
as
to
which
would
be
faster,
a
simple
switch
with
80 <br>>
possible
cases,
or
a
"nested
if"
that
uses
a
sorting
algorithm;
or <br>>
perhaps
even
more
plausible,
a
combination
of
the
two.<br>><br>>
Any
random
thoughts
are
appreciated
:)<br>><br>>
-- <br>>
-Rob<br>><br>>
Ben
Franklin
Quote:
"They
that
can
give
up
essential
liberty
to <br>>
obtain
a
little
temporary
safety
deserve
neither
liberty
nor
safety."<br>>
_______________________________________________<br>>
nflug
mailing
list<br>>
<a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br>>
<a href="http://www.nflug.org/mailman/listinfo/nflug" target="_blank">http://www.nflug.org/mailman/listinfo/nflug</a><br>><br>><br>><br>><br>><br>>
_______________________________________________<br>>
nflug
mailing
list<br>>
<a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br>>
<a href="http://www.nflug.org/mailman/listinfo/nflug" target="_blank">http://www.nflug.org/mailman/listinfo/nflug</a><br><br>_______________________________________________<br>nflug
mailing
list<br><a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br><a href="http://www.nflug.org/mailman/listinfo/nflug" target="_blank">http://www.nflug.org/mailman/listinfo/nflug</a><br></div><br></div></div>
</div></div><div class="WgoR0d"><br>
<hr size="1">Looking for last minute shopping deals? <a href="http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping" target="_blank">
Find them fast with Yahoo! Search.</a></div></div><br>_______________________________________________<br>
nflug mailing list<br>
<a href="mailto:nflug@nflug.org">nflug@nflug.org</a><br>
<a href="http://www.nflug.org/mailman/listinfo/nflug" target="_blank">http://www.nflug.org/mailman/listinfo/nflug</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>-Rob<br><br>Ben Franklin Quote: "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."