<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The cleanest would be for your arrays to be a single array of
arrays..<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>For example:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$myarray={1,2,3,4,5};<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$myotherarray={5,6,7,8,9};<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Would be a pain, but<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$arrays[0]={</span> <span style='font-size:11.0pt;font-family:
"Calibri","sans-serif";color:#1F497D'>1,2,3,4,5};<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$arrays[1]={5,6,7,8,9};<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Then you simply have a single assignment:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$myarraytouse=$array[$num];<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Mark<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
nflug-bounces@nflug.org [mailto:nflug-bounces@nflug.org] <b>On Behalf Of </b>Rob
Dege<br>
<b>Sent:</b> Thursday, February 21, 2008 2:57 PM<br>
<b>To:</b> nflug@nflug.org<br>
<b>Subject:</b> Re: [nflug] PHP (switch vs. nested if)<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
I'm not took concerned about readability.&nbsp; I already code in the style of
spaghetti, so cleanliness is not my first concern.&nbsp; 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<o:p></o:p></p>

<div>

<p class=MsoNormal>On Thu, Feb 21, 2008 at 1:11 PM, Robert Meyer &lt;<a
href="mailto:meyer_rm@yahoo.com">meyer_rm@yahoo.com</a>&gt; wrote:<o:p></o:p></p>

<div>

<div>

<p class=MsoNormal>Well, if you write the code in C, just create an array of
addresses of arrays and just directly access the array by position.&nbsp; Then
you don't even need any comparisons. :-)<br>
<br>
Cheers!<br>
<br>
Bob<o:p></o:p></p>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<p class=MsoNormal>--<br>
&quot;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.&quot;<br>
--Leonardo da Vinci<o:p></o:p></p>

<div>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>----- Original Message ----<br>
From: Franklin Kumro Jr &lt;<a href="mailto:fkumro@gmail.com" target="_blank">fkumro@gmail.com</a>&gt;<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.&nbsp; <br>
Multiple nested if statements hurt code readability, let alone a 1-80&nbsp; <br>
range.<br>
<br>
-Frank<br>
On Feb 21, 2008, at 11:43 AM, Timothy Finucane wrote:<br>
<br>
&gt; A switch is the most efficient method. I'm not sure how much speed&nbsp; <br>
&gt; performance is affected, but nested ifs would make the code&nbsp; <br>
&gt; difficult to read.<br>
&gt;<br>
&gt; -- <br>
&gt; Timothy J. Finucane<br>
&gt;<br>
&gt; <a href="http://www.speljamr.com" target="_blank">http://www.speljamr.com</a><br>
&gt;<br>
&gt; 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>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 2/21/08, Rob Dege &lt;<a href="mailto:livemotion@gmail.com"
target="_blank">livemotion@gmail.com</a>&gt; wrote:<br>
&gt; Hi, I'm wondering which would provide faster processing time based&nbsp; <br>
&gt; on the web page I'm building.<br>
&gt;<br>
&gt; I have a variable, let's call it $num.&nbsp; $num is an int that can
be&nbsp; <br>
&gt; anywhere from 1 to 80.&nbsp; Based on $num's value, an array is
assigned&nbsp; <br>
&gt; that is then used on the web page.&nbsp; Since this is for a web page,
I&nbsp; <br>
&gt; want to minimize the wait time as much as possible, and I'm guessing&nbsp;
<br>
&gt; that this could be a potential bottleneck.&nbsp; I have not written
the&nbsp; <br>
&gt; code yet, so I can't compare load times.&nbsp; I'm considering this
more&nbsp; <br>
&gt; of a &quot;do it the preferred way the first time&quot;.<br>
&gt;<br>
&gt; So I'm curious as to which would be faster, a simple switch with 80&nbsp; <br>
&gt; possible cases, or a &quot;nested if&quot; that uses a sorting
algorithm;&nbsp; or&nbsp; <br>
&gt; perhaps even more plausible, a combination of the two.<br>
&gt;<br>
&gt; Any random thoughts are appreciated :)<br>
&gt;<br>
&gt; -- <br>
&gt; -Rob<br>
&gt;<br>
&gt; Ben Franklin Quote: &quot;They that can give up essential liberty to&nbsp;
<br>
&gt; obtain a little temporary safety deserve neither liberty nor safety.&quot;<br>
&gt; _______________________________________________<br>
&gt; nflug mailing list<br>
&gt; <a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br>
&gt; <a href="http://www.nflug.org/mailman/listinfo/nflug" target="_blank">http://www.nflug.org/mailman/listinfo/nflug</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; nflug mailing list<br>
&gt; <a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><br>
&gt; <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><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

</div>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div class=MsoNormal align=center style='text-align:center'>

<hr size=1 width="100%" align=center>

</div>

<p class=MsoNormal>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><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p>

</div>

<p class=MsoNormal><br>
<br clear=all>
<br>
-- <br>
-Rob<br>
<br>
Ben Franklin Quote: &quot;They that can give up essential liberty to obtain a
little temporary safety deserve neither liberty nor safety.&quot; <o:p></o:p></p>

</div>

</body>

</html>