<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><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 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 <fkumro@gmail.com><br>To: nflug@nflug.org<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 ymailto="mailto:livemotion@gmail.com" href="mailto:livemotion@gmail.com">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 ymailto="mailto:nflug@nflug.org" 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>><br>><br>><br>><br>> 
_______________________________________________<br>> 
nflug 
mailing 
list<br>> 
<a ymailto="mailto:nflug@nflug.org" 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>_______________________________________________<br>nflug 
mailing 
list<br><a ymailto="mailto:nflug@nflug.org" 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></div><br></div></div><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"> 
Find them fast with Yahoo! Search.</a></body></html>