<br>nah, this won&#39;t work, since the arrays I&#39;m referencing are already two-dimensional arrays.&nbsp; I mean I could create one large 2-dim array, and pass that to each page every single time, but that would take up more memory than it would need to.<br>
<br>Each 2-dim array has at least 5 entries.&nbsp; So that would be over 400 entries in on big array.&nbsp; Seems bloated to load that big of an array when I only need 5 entries from it.<br><br>That&#39;s why I decided a simple conditional statement would help me to break down the array.&nbsp; I figured the smaller the array, the faster the script could process it, and the faster the page would load.&nbsp; My only bottleneck appeared to be the selection of the appropriate 2-dim array.<br>
<br>Sorry if I made the problem sound easier than what it was.&nbsp; I wanted to spare the pain of details :)<br><br>-Rob<br><br><div class="gmail_quote">On Thu, Feb 21, 2008 at 3:02 PM, Mark Musone &lt;<a href="mailto:mmusone@shatterit.com">mmusone@shatterit.com</a>&gt; 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 link="blue" vlink="purple" lang="EN-US">

<div>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">The cleanest would be for your arrays to be a single array of
arrays..</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">For example:</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">$myarray={1,2,3,4,5};</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">$myotherarray={5,6,7,8,9};</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">Would be a pain, but</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">$arrays[0]={</span> <span style="font-size: 11pt; color: rgb(31, 73, 125);">1,2,3,4,5};</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">$arrays[1]={5,6,7,8,9};</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">Then you simply have a single assignment:</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">$myarraytouse=$array[$num];</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">Mark</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">

<p><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;">
<a href="mailto:nflug-bounces@nflug.org" target="_blank">nflug-bounces@nflug.org</a> [mailto:<a href="mailto:nflug-bounces@nflug.org" target="_blank">nflug-bounces@nflug.org</a>] <b>On Behalf Of </b>Rob
Dege<br>
<b>Sent:</b> Thursday, February 21, 2008 2:57 PM<br>
<b>To:</b> <a href="mailto:nflug@nflug.org" target="_blank">nflug@nflug.org</a><div><div></div><div class="Wj3C7c"><br>
<b>Subject:</b> Re: [nflug] PHP (switch vs. nested if)</div></div></span></p>

</div><div><div></div><div class="Wj3C7c">

<p>&nbsp;</p>

<p style="margin-bottom: 12pt;"><br>
I&#39;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 &#39;C&#39; you language speak of... unless you forgot to add
the &#39;#&#39; after it ;)<br>
<br>
-Rob</p>

<div>

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

<div>

<div>

<p>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&#39;t even need any comparisons. :-)<br>
<br>
Cheers!<br>
<br>
Bob</p>

<div>

<p>&nbsp;</p>

</div>

<p>--<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</p>

<div>

<div>

<div>

<p style="margin-bottom: 12pt;">&nbsp;</p>

<div>

<p>----- 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&#39;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&#39;m wondering which would provide faster processing time based&nbsp; <br>
&gt; on the web page I&#39;m building.<br>
&gt;<br>
&gt; I have a variable, let&#39;s call it $num.&nbsp; $num is an int that can
be&nbsp; <br>
&gt; anywhere from 1 to 80.&nbsp; Based on $num&#39;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&#39;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&#39;t compare load times.&nbsp; I&#39;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&#39;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></p>

</div>

<p>&nbsp;</p>

</div>

</div>

</div>

</div>

<div>

<p>&nbsp;</p>

<div style="text-align: center;" align="center">

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

</div>

<p>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></p>

</div>

</div>

<p style="margin-bottom: 12pt;"><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></p>

</div>

<p><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; </p>

</div></div></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: &quot;They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.&quot;