<br>nah, this won't work, since the arrays I'm referencing are already two-dimensional arrays. 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. So that would be over 400 entries in on big array. Seems bloated to load that big of an array when I only need 5 entries from it.<br><br>That's why I decided a simple conditional statement would help me to break down the array. I figured the smaller the array, the faster the script could process it, and the faster the page would load. 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. 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 <<a href="mailto:mmusone@shatterit.com">mmusone@shatterit.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 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);"> </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);"> </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);"> </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);"> </span></p>
<p><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </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);"> </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);"> </span></p>
<p><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </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);"> </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> </p>
<p style="margin-bottom: 12pt;"><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</p>
<div>
<p>On Thu, Feb 21, 2008 at 1:11 PM, Robert Meyer <<a href="mailto:meyer_rm@yahoo.com" target="_blank">meyer_rm@yahoo.com</a>> 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. Then
you don't even need any comparisons. :-)<br>
<br>
Cheers!<br>
<br>
Bob</p>
<div>
<p> </p>
</div>
<p>--<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</p>
<div>
<div>
<div>
<p style="margin-bottom: 12pt;"> </p>
<div>
<p>----- 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></p>
</div>
<p> </p>
</div>
</div>
</div>
</div>
<div>
<p> </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: "They that can give up essential liberty to obtain a
little temporary safety deserve neither liberty nor safety." </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: "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."