<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geek Gumbo &#187; Web Development</title>
	<atom:link href="http://www.geekgumbo.com/category/webdev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekgumbo.com</link>
	<description>A potpourri of Web Development, Linux, and Windows tips, tidbits, and observations</description>
	<lastBuildDate>Thu, 02 Feb 2012 20:31:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The PHP Switch Statement</title>
		<link>http://www.geekgumbo.com/2012/02/02/the-php-switch-statement/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-php-switch-statement</link>
		<comments>http://www.geekgumbo.com/2012/02/02/the-php-switch-statement/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 20:31:28 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4271</guid>
		<description><![CDATA[The PHP switch statement is a good substitute for a lot of "if, "else", and "elseif" statements. The switch statement is much more efficient than the "if", "elseif" statements, however there are some quirks that you should be aware of &#8230; <a class="more-link" href="http://www.geekgumbo.com/2012/02/02/the-php-switch-statement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The PHP switch statement is a good substitute for a lot of "if, "else", and "elseif" statements.  The switch statement is much more efficient than the "if", "elseif" statements, however there are some quirks that you should be aware of in using switch.   This article came when I wanted to do an "or" condition in one of the case tags.  As usual, it took me awhile to find what I wanted.  I thought it would help if I put all the quirks in one article.  </p>
<p>First, lets look at the basic switch statement. </p>
<pre class="brush:php">
include "chk.php";
$var = 0;
new chk($var);
SwitchDemo($var);
function SwitchDemo($var)
{
  switch ($var)
  {
    case 0:
		echo "Hello";
		break;
    case 1:
	        echo " World!";
		break;
    case 2:
	        echo "The real McCoy";
	        break;
    case 3:
                echo "Went too far";
	        break;
    case 4 :
		if ($type == "string" ) {
                    $myarray = array_push($buildarr, $type);
                    break;
                }
		break;
    default:
	    echo "went way too far";
	    break;
	}
}
</pre>
<p>Here's the code we'll use initially to test things out.  A word of explanation.  Include "chk.php" is my free variable checking class that you can <a href="http://www.newchk.com/" title="NewChk.com">read about and download here</a>.  To use the class, I simply say "new chk($var);".  The output is in the picture below.  The output says $var is an integer set to "0" that was called in my test script file, "switch.php", on line 21.  The output of the switch statement is "Hello".</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch152.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch152.png" alt="" title="switch15" width="600" height="99" class="aligncenter size-full wp-image-4279" /></a></p>
<p>This is a standard switch statement that we'll start with so you can quickly refer to the syntax when needed.  The switch statement executes a different section of code depending on which case is true.   The switch variable to be checked should be in parenthesis, and each case tag ends with a ":", a colon, although if you messed up and used a semicolon, I think you'll find that it still works.  I'll let you test that out on your own.  Note the brackets surrounding all the case and default tags.  Also, notice in Case 4, you can have a fairly complex series of commands in the case block, not just one or two lines.  We'll leave Case 4 out in the rest of this article just to keep things simple.  </p>
<p>The first thing to know is the switch statement does a "loose" comparison between the value in the switch parenthesis and the case value, as opposed to a strict comparison.  This would be like using a == in an if statement, instead of a ===.  Let's just say that switch does a pretty good job, and if there's any doubt, re-do the variable to make sure there's no ambiguity, that can mean, just making the comparison all integers.  If your using integers to compare, you do not need quotes around the integers as shown in our first example.  With strings, put quotes around the string.</p>
<p>OK, lets move on.  The default case is used, if none of the other case statements are true.  A little known fact is the case statements, and the default statement, don't need to be in any sort of order.  Let's move the default up, change the case statements around, and change our variable to 2 to better show this.  Here's the code scrambled.  I'll cut down the code to show just the switch statement.  The other code is still running.</p>
<pre class="brush:php">
	switch ($var)
	{
	    case 3:
              echo "Went too far";
	      break;
	    default:
	      echo "went way too far";
	      break;
            case 1:
	      echo "World!";
              break;
	case 0:
   	      echo "Hello";
	      break;
    case 2:
	    echo "The real McCoy";
	    break;
</pre>
<p>And here's the output:</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch25.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch25.png" alt="" title="switch25" width="600" height="106" class="aligncenter size-full wp-image-4284" /></a></p>
<p>Next, we want to talk about "break" and "continue".  "break;" breaks you out of the switch statement all together.  You're done your filtering, and you're moving on. "continue;" means move to the next case block.  Let's show this, we'll put the switch back in order and use a continue.</p>
<pre class="brush:php">

switch ($var)
{
    case 0:
		echo "Hello";
		continue;
    case 1:
	    echo "World!";
		break;
    case 2:
	    echo "The real McCoy";
	    break;
    case 3:
        echo "Went too far";
	    break;
    default:
	    echo "went way too far";
	    break;
}
</pre>
<p>Here's the output:</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch35.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch35.png" alt="" title="switch35" width="600" height="106" class="aligncenter size-full wp-image-4287" /></a></p>
<p>I know you were expecting "Hello World", lol.  No, even though we are "continuing" to match case blocks, we still have to match.  Which brings me to why I wrote the article: How can I output "Hello World!" ?</p>
<p>We'll use a not well known feature of the switch, the "fall through" in the switch statement.  If we take out the continue, and leave the break on case 1, we'll get close to our desired results.  Here's the code:</p>
<pre class="brush:php">
switch ($var)
{
    case 0:
	    echo "Hello";
    case 1:
	    echo " World!";
		break;
    case 2:
	    echo "The real McCoy";
	    break;
    case 3:
            echo "Went too far";
	    break;
    default:
	    echo "went way too far";
	    break;
}
</pre>
<p>Here's the output:</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch55.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch55.png" alt="" title="switch55" width="600" height="109" class="aligncenter size-full wp-image-4289" /></a></p>
<p>In this case, there was no break for Case 0, so when the $var was 0, it outputs "Hello World!"  It fell through to Case 1.  What happens if we set the $var to 1.  Here's the output.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch65.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch65.png" alt="" title="switch65" width="600" height="107" class="aligncenter size-full wp-image-4290" /></a></p>
<p>Here we did not match the "0", so "Hello" did not output, and because the HTML tags were not correct the CSS styling did not load, and make "World!" bigger.  Let's fix this and make the switch statement really useful.  Here's the code:</p>
<pre class="brush:php">
switch ($var)
{
    case 7:
    case 8:
    case 0:
    case 1:
	    echo "Hello World!";
		break;
    case 2:
	    echo "The real McCoy";
	    break;
    case 3:
        echo "Went too far";
	    break;
    default:
	    echo "went way too far";
	    break;
	}
</pre>
<p>Here's the output:</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch85.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch85.png" alt="" title="switch85" width="600" height="101" class="aligncenter size-full wp-image-4292" /></a></p>
<p>Woo horsey!   What's going on here?  We put in a variable of 8 and we get "Hello World!" What happen is the case block matched the 8 and fell through to case 1 and out came "Hello World!". We then broke out of the switch statement.  What this means to you is that you can use "OR" conditions with the switch statement.  </p>
<p>Instead of:<br />
<code></p>
<pre class="brush:php">

if( $var == 7 || $var == 8 || $var == 0 || $var == 1) {

}
</pre>
<p></code></p>
<p>We can use our switch statement above, which seems a lot easier to me, and more important less prone to syntax errors when we have "OR" statements.</p>
<p>One last thing, we can use calculations in our matches.  Let do a final example.  Here we'll go back to all the code, and use more than one variable.  Here's the code:</p>
<pre class="brush:php">

include "chk.php";
$var1 = 1;
$var4 = 4;
new chk($var1, $var4);

SwitchDemo($var1, $var4);
function SwitchDemo($var1, $var4)
{
switch ($var1 + $var4)
{
    case 7:
    case 8:
    case 0:
    case 1:
	    echo "Hello World!";
	    break;
    case (2 + 3):
	    echo "The real McCoy";
	    break;
    case 3:
            echo "Went too far";
	    break;
    default:
	    echo "went way too far";
	    break;
	}
}
</pre>
<p>Here's the output:</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch115.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/switch115.png" alt="" title="switch115" width="600" height="132" class="aligncenter size-full wp-image-4294" /></a></p>
<p>Here we used calculations, a simple add, in both the switch parameter statement and the case parameter, and we get "The real McCoy." This is equivalent to:</p>
<pre class="brush:php">
if( $var1 && $var2)  {

}
</pre>
<p>We've used switch to add variables, and check for an "AND" condition.  You can use this to concatenate strings, if you like.  You can see the versatility of the switch statement.</p>
<p>In conclusion, the switch statement is more efficient than the "elseif" type of statement.  The interpreter makes a list of case comparisons, and then goes right to the case that matches instead of checking every comparison one at a time.  Hopefully, you won't shy away from using the switch statement in the future now that you know all the ins and outs. Chow, until next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2012/02/02/the-php-switch-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 7.1 Review</title>
		<link>http://www.geekgumbo.com/2012/01/21/netbeans-7-1-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=netbeans-7-1-review</link>
		<comments>http://www.geekgumbo.com/2012/01/21/netbeans-7-1-review/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 18:08:25 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Software Reviews]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4225</guid>
		<description><![CDATA[One of outcomes of switching jobs is you lose some of your favorite tools.  For me that was Zend Studio.  Having done PHP development full time for many years, Zend Studio had become my IDE of choice. Since Zend Studio &#8230; <a class="more-link" href="http://www.geekgumbo.com/2012/01/21/netbeans-7-1-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbaens7.png"><img class="alignleft size-full wp-image-4228" title="netbaens7" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbaens7.png" alt="" width="200" height="126" /></a>One of outcomes of switching jobs is you lose some of your favorite tools.  For me that was Zend Studio.  Having done PHP development full time for many years, Zend Studio had become my IDE of choice.</p>
<p>Since Zend Studio costs money, as a newbie to my new company, I didn't see a lot of Zend Studio's installed.  In fact, I saw few IDE's.  Most of the edits were done on a Linux server running Vim. This seemed a little archaic to me.  I wanted to set up my beloved work environment, back to open-source.</p>
<p>Naturally, I downloaded Eclipse PDT based on the Helios release, on which Zend Studio is built.  I had used Eclipse before Zend Studio, and so this was pretty close to home.  All the menus and functionality, except for some of the Zend Studio features, are the same.</p>
<p>In the process of configuring Eclipse, I, of course, started messing with preferences.  Anyone who has used Eclipse understands what a nightmare the Eclipse preferences are.  It takes you quite a bit of time to initially configure preferences.  So you don't have to reconfigure then again, you export your preferences and import them to the new Eclipse environments.</p>
<p>I did an import of my Zend Studio preferences and then started changing some setting, and I had a hiccup.  The hiccup was Eclipse balked at some setting I set, and blew away my entire workspace.  I'm guessing Zend Studio preferences have problems with importing to Eclipse.  I had to reload everything including re-configuring my preferences.  What a nightmare.</p>
<p>When things like this happen, I get pissed, and go looking for new tools.  After a preliminary search showed that Netbeans had good reviews, I decided to give it a try.  I had tried Netbeans before, and found it wanting for PHP development, but that was four years ago.  It deserved another look.</p>
<div id="attachment_4229" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans_startup15.jpg"><img class="size-full wp-image-4229" title="netbeans_startup15" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans_startup15.jpg" alt="" width="600" height="432" /></a><p class="wp-caption-text">NetBeans Initial Start Up Screen</p></div>
<p>&nbsp;</p>
<p>Netbeans is a Java application and requires Java to run, which is probably already loaded on your computer.  The Netbeans license is owned by Oracle from its acquisition of Sun, but it is a free and open source IDE.</p>
<p>Since PHP is now an object-oriented language, like Java, NetBeans has incorporated PHP into its editor.  You have a choice to install NetBeans with just the PHP bundle, which is what I did, since I do not do a lot of Java work.</p>
<p>The Netbeans 7.1 download and install was seamless. The installer downloads 46.6 Mb, which grows to 152.5 Mb on install.  By the way, my Eclipse Helios folder checks in at 390 Mb. The installation took about 5 minutes and NetBeans came up quickly and easily.</p>
<div id="attachment_4234" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/Netbeans_proj25.png"><img class="size-full wp-image-4234" title="Netbeans_proj25" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/Netbeans_proj25.png" alt="" width="600" height="431" /></a><p class="wp-caption-text">NetBeans with various Windows open</p></div>
<p>&nbsp;</p>
<p>If you do a feature by feature analysis of Eclipse and Netbeans, you'll find that both IDE's pretty much have the same features and functionality.  You'll find several good articles on the web about this, so I won't go into individual features here.</p>
<div id="attachment_4235" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans85.png"><img class="size-full wp-image-4235" title="netbeans85" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans85.png" alt="" width="600" height="432" /></a><p class="wp-caption-text">NetBeans main editor window with other windows closed</p></div>
<p>&nbsp;</p>
<p>If your doing Java development, Netbeans should be your IDE of choice, since it was built with Java development in mind.  What surprised me was how far Netbeans has come as a PHP development environment.  If your a PHP Developer, NetBeans has integrated support for Git, Debugging, PHPUnit testing, PHPDoc, Smarty templates, Symfony Framework, and the Zend framework. Need I say more.</p>
<div id="attachment_4231" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans-php45.png"><img class="size-full wp-image-4231" title="netbeans-php45" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans-php45.png" alt="" width="600" height="517" /></a><p class="wp-caption-text">NetBeans PHP preference screen</p></div>
<p>&nbsp;</p>
<p>If both IDE's pretty much have the same functionality, what is the difference between the two?  Well, it comes down to the feel of the IDE as your using them.</p>
<p>I thought about good analogies and similes for the two editors.   Here's my take.  Eclipse is like an old car that you keep fixing up, it's serviceable and runs good, but every once in a while, you get irritated, because something doesn't work right.  Netbeans seems like a new BMW sports car.  If Eclipse is a house built with a series of additions, Netbeans is a house built from the ground up by an architect.  Eclipse feels bloated.  Netbeans feels integrated, not like your bringing up a separate application every time you go to a new area of the IDE.</p>
<p>One major weakness in Eclipse is setting preferences on how you want the editor to work.  Each plugin added to Eclipse has its own preferences, every section of Eclipse has it own preferences.  What that means is setting preferences is a nightmare.  Not only that, if you set a preference in one area, it might not be set in another, and may collide with another preference, sometime throwing errors, or shutting down the editor.  I've had all of this happen.</p>
<p>In contrast, NetBeans preferences are a pleasure.  Colors and fonts are configured in one tab, PHP in another tab.  You can set all colors and fonts for all languages at once, not like Eclipse.</p>
<div id="attachment_4232" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans_options35.png"><img class="size-full wp-image-4232" title="netbeans_options35" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans_options35.png" alt="" width="600" height="513" /></a><p class="wp-caption-text">NetBeans Fonts and Colors Preference Screen</p></div>
<p>&nbsp;</p>
<p>In all fairness to Eclipse, I'm comparing this to Eclipse Helios PDT.  I downloaded the Eclipse Indigo 64bit and added the PDT plugin, and I find this version quicker,  and much more stable.  I would recommend Eclipse PDT users uninstall Helios, download Indigo, and add PDT.  I think you'll like it  better, if you stay with Eclipse.</p>
<p>In conclusion, because of problems I've had configuring colors with Eclipse, even using the <a title="Eclipse Color Theme Plugin" href="http://www.geekgumbo.com/2011/12/07/changing-eclipse-syntax-colors/">Eclipse Color Theme Plugin</a> I wrote about in another post, I find myself using NetBeans to write my code.</p>
<p>I highly recommend you download and try NetBeans.  You can have both IDE's running at the same time without conflicts.  If you don't like NetBeans, you can stay with Eclipse, but in the process of using both, I think you'll find yourself gradually moving to NetBeans as your IDE of choice.</p>
<div id="attachment_4236" class="wp-caption aligncenter" style="width: 189px"><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans3.0.jpeg"><img class="size-full wp-image-4236" title="netbeans3.0" src="http://www.geekgumbo.com/wp-content/uploads/2012/01/netbeans3.0.jpeg" alt="" width="179" height="179" /></a><p class="wp-caption-text">The NetBeans Icon</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2012/01/21/netbeans-7-1-review/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>PHP array_push, and other array manipulators</title>
		<link>http://www.geekgumbo.com/2012/01/12/php-array_push-array_pop-array_shift-array_unshift/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-array_push-array_pop-array_shift-array_unshift</link>
		<comments>http://www.geekgumbo.com/2012/01/12/php-array_push-array_pop-array_shift-array_unshift/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 20:35:45 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[Sorting Arrays]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4140</guid>
		<description><![CDATA[Every once and a while I like to take a closer look at a particular function that I use quite frequently. This let's me make sure I'm using that particular function to the best possible effect. I find it also &#8230; <a class="more-link" href="http://www.geekgumbo.com/2012/01/12/php-array_push-array_pop-array_shift-array_unshift/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/antarray15.jpg"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/antarray15.jpg" alt="" title="antarray15" width="150" height="113" class="alignleft size-full wp-image-4193" /></a>Every once and a while I like to take a closer look at a particular function that I use quite frequently.  This let's me make sure I'm using that particular function to the best possible effect.  I find it also shifts the center of attention from a task to how the function operates.  A different look so to speak.  Today, I want to cover the PHP array manipulator family functions that include: <span style="color:red;">array_push</span>, <span style="color:red;"> array_pop</span>, <span style="color:red;">array_shift</span> and <span style="color:red;">array_unshift</span>.  </p>
<p>All the examples below are visualized with my free, open-source, variable checker that you are welcome to download from my newchk site at <a href="http://www.newchk.com/" title="newchk">www.newchk.com</a>  Documentation on how to use it is on the site.  </p>
<p><span style="color:blue;"><strong>ARRAY_PUSH</strong></span></p>
<p>Array_push($new_array, $var1, $var2, ...) pushes one or more array elements on to the end of an array, in this case, we'll use $new_array as our array.  Seems simple enough.  I want to create a new array, and add some variables to it. Let's take a look.</p>
<p>Let's set up our new array.<br />
<code></p>
<pre class="brush:php">
$new_array = array();
$var1 = "buick";
$var2 = "ford";
$var3 = "toyota";
array_push($new_array, $var1, $var2, $var3);
</pre>
<p></code><br />
Let's take a look at $new_array;</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array151.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array151.png" alt="" title="array15" width="600" height="75" class="aligncenter size-full wp-image-4167" /></a></p>
<p>If $new_array already exists with elements in it, then new variables are appended to the end of the already existing array.  Let's show that.<br />
<code></p>
<pre class="brush:php">
$var_food1 = "cheese";
$var_food2 = "meat";
$var_food3 = "potatoes";
array_push($new_array, $var_food1, $var_food2, $var_food3);
</pre>
<p></code><br />
Here's what the $new_array looks like now.  </p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array251.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array251.png" alt="" title="array25" width="600" height="128" class="aligncenter size-full wp-image-4171" /></a></p>
<p>Some things to note about the array_push() function.  It is a function, so there is no equal sign used with array_push.  The order the variables are pushed on to the end of the array are in the order their listed in array_push.  We can also use associative keys with array_push(), like so.</p>
<p><code></p>
<pre class="brush:php">
$var_ball1 = "football";
$var_ball2 = "the rock";
$var_ball3 = "hardball";
$ball_array = array("ball_football" => $var_ball1, "ball_basketball" =>$var_ball2, "ball_baseball" =>$var_ball3);
array_push($new_array, $ball_array );
</pre>
<p></code><br />
Here's what the $new_array looks like now.  </p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array_push351.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array_push351.png" alt="" title="array_push35" width="600" height="196" class="aligncenter size-full wp-image-4173" /></a></p>
<p>We've done a little more here than just assign associative keys to the array.  We've jumped to what is called a multi-dimensional array.  We now have an array within an array.  If you look at the code above you see when working with multi-dimensional arrays, you build the inner array first, in this case the $ball_array, and then do an array_push using $ball_array as the variable in the array_push.</p>
<p>What got me to write this article was I was trying to do an array_push in a foreach loop using a multi-dimensional array.  This is not well documented on the Internet.  I had to look for awhile to find the proper syntax.  When that happens I tend to write an article about it.  The trick is to make a separate array variable before doing the array_push, and then add that array as a variable to the array_push().</p>
<p>Where do you most often use the array_push() function?  Most of the time it's with a foreach loop, where your repetitively looping through an array, and creating a new subset of the array with array_push.  Let's see.<br />
<code></p>
<pre class="brush:php">
$for_array = array();
$i = 1;
foreach( $new_array as $row)
{
	if($i < 7 )
	{
		array_push($for_array, $row );
	}
	$i ++;
}
</pre>
<p></code></p>
<p>Here, with a foreach loop, we've removed the second array, and are back to a one dimensional array, called $for_array.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array_push451.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array_push451.png" alt="" title="array_push45" width="600" height="125" class="aligncenter size-full wp-image-4175" /></a></p>
<p><span style="color:blue;"><strong>ARRAY_POP</strong></span></p>
<p>Array_pop($array) pops an element off the end of an array.  Let's do it </p>
<p><code></p>
<pre class="brush:php">

$spuds = "";
$spuds = array_pop($for_array);
</pre>
<p></code><br />
Our $for_array now is minus the last element in the previous array. That element is now in a separate $variable called $spuds.  Array_pop() removes the last element in the array, which you can then put into a separate variable.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array551.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array551.png" alt="" title="array55" width="600" height="150" class="aligncenter size-full wp-image-4177" /></a></p>
<p><span style="color:blue;"><strong>ARRAY_SHIFT</strong></span></p>
<p>What if we wanted to remove the first element in the array, instead of the last, like we do with array_pop().  We'll we use array_shift to do this, like so.<br />
<code></p>
<pre class="brush:php">

$gm = "";
$gm = array_shift($for_array);
</pre>
<p></code><br />
The $for_array we started with is getting shorter as the first variable in the array is removed, and put, in this case, in the variable $gm.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array651.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array651.png" alt="" title="array65" width="600" height="132" class="aligncenter size-full wp-image-4179" /></a></p>
<p><span style="color:blue;"><strong>ARRAY_UNSHIFT</strong></span></p>
<p>Finally, since array_push added new variables to the end of the array, you probably have guessed that there is a function that adds variable to the front of the array, and you'd be right. I present to you, array_unshift().  Array_unshift() puts the new variable as the first element in your array.  Let's do it.<br />
<code></p>
<pre class="brush:php">

$gm2 = "cadillac";
array_unshift($for_array, $gm2);
</pre>
<p></code><br />
Our array now looks like this.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2012/01/array751.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2012/01/array751.png" alt="" title="array75" width="600" height="113" class="aligncenter size-full wp-image-4180" /></a></p>
<p>We've replaced the "buick" we've taken off the top of the array with array_shift, and upgraded to a "cadillac" with array_unshift.  Nice trade-up.</p>
<p>If your working with multi-dimensional arrays, the key is to treat the nested arrays as a single array variable, and then use the four functions we've covered: array_push, array_pop, array_shift and array_unshift with that single array variable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2012/01/12/php-array_push-array_pop-array_shift-array_unshift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tools</title>
		<link>http://www.geekgumbo.com/2011/12/31/php-tools/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-tools</link>
		<comments>http://www.geekgumbo.com/2011/12/31/php-tools/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 15:15:37 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4097</guid>
		<description><![CDATA[Happy New Year!  For the start of the new year, I thought I'd review some of the PHP tools you should be learning, and using, to up your game in the coming year. One of the challenges of a technical &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/12/31/php-tools/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/images.jpeg"><img class="alignleft size-full wp-image-4106" title="images" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/images.jpeg" alt="" width="267" height="189" /></a>Happy New Year!  For the start of the new year, I thought I'd review some of the PHP tools you should be learning, and using, to up your game in the coming year.</p>
<p>One of the challenges of a technical career is that your always wondering if you learn a new technology, if its going to be a waste of time.  You're constantly learning new things, and every time you're presented with the challenge of implementing something you've never done before you have to wonder if this technology will be around in another three years.  Technology moves that fast.</p>
<p>As you gain more experience in your chosen expertise, you get more selective in the tools your willing to spend time to learn.  Along those lines I thought it might be nice to do a light over view of where I see PHP tools at this moment in time.  These are the tools that I hear currently mentioned the most on the web, in workshops, and conferences.  In other words, the current tools of choice, and the tools you should seriously consider working with and learning.</p>
<p>First of all, we all should be using object-oriented coding.  <span style="color: #008080;"><a title="PHP 5.3" href="http://php.net/releases/5_3_0.php"><span style="color: #008080;">PHP 5.3</span></a></span> is the way to go for now. The old procedural coding, for the most part, is dead.  I believe colleges are all teaching object-oriented now, so this is not a big deal.</p>
<p>Although, it seems MySQL is still the database of choice, I've seen a lot of use of two other databases you should be considering.  A file based <span style="color: #008080;"><a title="SQLite" href="http://www.sqlite.org/"><span style="color: #008080;">SQLite</span></a></span>.  It works great, and is super quick, except when you start to get into heavy transactions.  It's used to replace configuration and XML files, works great for mobile devices, and for small and medium size web site databases.</p>
<p>You might think that MySQL kicks in about then, but if you want to consider an alternative, I've been seeing the <span style="color: #008080;"><a title="PostgreSQL" href="http://www.postgresql.org/"><span style="color: #008080;">PostgreSQL</span></a></span> database coming on strong.  For one thing, it's not Oracle controlled.  Oracle starts charging after you cross over a certain usage line.  It is the database of choice for raw speed doing complex tasks, like constantly displaying data for constantly updating weather monitors.</p>
<p>For JavaScript, hands down <span style="color: #008080;"><a title="jQuery" href="http://jquery.com/"><span style="color: #008080;">jQuery</span></a></span> has been adopted universally.  Other tools I hear mentioned are <span style="color: #008080;"><a title="Mootools" href="http://mootools.net/"><span style="color: #008080;">Mootools</span></a></span>, and <span style="color: #008080;"><a title="Dojo" href="http://dojotoolkit.org/"><span style="color: #008080;">Dojo</span></a></span>.   For Ajax applications, I again hear jQuery.  jQuery has become so popular that is incorporated into a lot of PHP frameworks.</p>
<p>Speaking of PHP frameworks, there is a lot of buzz surrounding <span style="color: #008080;"><a title="Zend Framework 2" href="http://framework.zend.com/wiki/pages/viewpage.action?pageId=42303506"><span style="color: #008080;">Zend Framework 2</span></a></span>. The developers have reworked this PHP Framework to improve overall performance and take advantage of all the new features in PHP 5.3.  There has been an open forum during the development to get the best ideas from other PHP developers and implement them.  Consideration has been given to improving performance every step of the way.  The framework is currently in Beta release.  The documentation on the web on how to use this new release is starting to swell.  There are a lot of other good frameworks out there, but you should still spend some time to get to know ZF2, as its called, because of the extensive libraries of code available to ease your coding tasks.</p>
<p>Second, PDO and ORM for the database to PHP object type mismatch are important technologies.  You use PDO, for example, if you started with a MySql database and wanted to switch to the PostgreSQL database.  PDO makes switching databases easier.  ORM translates SQL database output to PHP objects for use in your application.  It makes coding database applications faster and easier with less problem in getting SQL queries correct.</p>
<p>There are many ORM options out there, however, the new Zend Framework 2 has settled on using Doctrine 2.  This makes <span style="color: #008080;"><a title="Doctrine 2" href="http://www.doctrine-project.org/"><span style="color: #008080;">Doctrine 2</span></a></span> the de facto standard to learn for applying PDO and ORM to your application, and make no mistake, don't let those SQL bigots get to you.  It is a benefit to code with an ORM.  Take it from me that has done it both ways.</p>
<p>A lot of frameworks now include testing components in the framework.  The testing component that is fast becoming the de facto standard is <span style="color: #008080;"><a title="PHPUnit" href="http://www.phpunit.de/manual/3.6/en/automating-tests.html"><span style="color: #008080;">PHPUnit</span></a></span>.  One new technology you should gradually start applying is unit tests.  The best way to start is to set up the testing environment, and write a couple of tests for your project, then gradually write a couple of more, expanding your test suite. Pretty soon you'll get the hang of it and it will become second nature.</p>
<p>For version control the current hot software is <span style="color: #008080;"><a title="Git" href="http://git-scm.com/"><span style="color: #008080;">Git</span></a></span>.  You should be using version control for all your projects.  Because Git is so popular, <span style="color: #008080;"><a title="Github" href="https://github.com/"><span style="color: #008080;">GitHub</span></a></span> has become a mecca for releasing open source software, install Git, and join GitHub. Git runs on all platforms, if you haven't used version control software it's time to start.</p>
<p>For documenting your code you should be following the <span style="color: #008080;"><a title="phpDocumentor" href="http://www.phpdoc.org/"><span style="color: #008080;">phpDocumentor</span></a></span> syntax.  phpDocumentor has been the standard for a couple of years now.  My time spent learning how to document my code properly was well worth the time I spent looking over the phpDocumentor documentation.</p>
<p>Coding to a standard, so that all your code is written in the same format is good coding.  To help you check your code for syntax errors, and format your code for your custom style automatically, use <span style="color: #008080;"><a title="PHP Code Sniffer" href="http://pear.php.net/package/PHP_CodeSniffer/redirected"><span style="color: #008080;">PHP Code Sniffer</span></a></span>.  This will also check your  CSS, and JavaScript. PHP Code Sniffer is installed through the Pear library.</p>
<p>Incidentally, if you're wondering what good code formatting looks like, I can recommend two references that I've run across.  One is on the web, in the <span style="color: #008080;"><a title="Kohana styling" href="http://kohanaframework.org/3.0/guide/kohana/conventions"><span style="color: #008080;">Kohana</span></a></span> framework documentation, and the other is in a book, "<span style="color: #008080;"><a title="Advanced PHP Programming" href="http://www.amazon.com/Advanced-PHP-Programming-George-Schlossnagle/dp/0672325616/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1325341062&amp;sr=1-1"><span style="color: #008080;">Advanced PHP Programming</span></a></span>" by George Schlossnagle.  The important thing on code formatting is to choose a style and consistently use it in all your coding.</p>
<p>If you'd like a report on your code base, the number of lines of code, the complexity, the percentage of comments, number of classes, possible coding violations, bad practices with a bunch of other metrics.  The tool I hear mentioned is <span style="color: #008080;"><a title="Sonar" href="http://docs.codehaus.org/display/SONAR/Documentation"><span style="color: #008080;">Sonar</span></a></span>.</p>
<p>To build your application, run your test suite, and run every thing else with one command, like a "make" file, the application you want is <span style="color: #008080;"><a title="Phing" href="http://www.phing.info/trac/"><span style="color: #008080;">Phing</span></a></span>.</p>
<p>If you would like to automate several projects and run them on a schedule, "<span style="color: #008080;"><a title="CruiseControl" href="http://cruisecontrol.sourceforge.net/   "><span style="color: #008080;">CruiseControl</span></a></span>," will do that for you.  CruiseControl offers flexible scheduling, notifications, and integrates with Phing with a "<span style="color: #008080;"><a title="PHP Under Control" href="http://phpundercontrol.org/"><span style="color: #008080;">PHP Under Control</span></a></span>" plugin.</p>
<p>To solve your scaling problems for those web sites that start out small and get bigger really fast, and to get off of having to depend on your own hardware solution, or that of a commercial hosting company, there is a lot of good reasons to try out <span style="color: #008080;"><a title="Amazon Web Services" href="http://aws.amazon.com/"><span style="color: #008080;">Amazon Web Services</span></a></span>. There are other services out there, but Amazon stands way above all the others in features and pricing.</p>
<p>Don't get me wrong.  In each one of these categories other companies and developers have spent their time creating tools that do the same thing.  These other tools may be just as good, or even better.  I don't mean to put any of these other tools down.  All I'm suggesting is, at this moment in time, this is a tool you should consider spending your time learning, and that it probably would not waste your time.  If you prefer another tool, go for it, and let me know so I can take a look at it too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/12/31/php-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the Focus on the Google Home Page</title>
		<link>http://www.geekgumbo.com/2011/12/10/setting-the-focus-on-the-google-home-page/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-the-focus-on-the-google-home-page</link>
		<comments>http://www.geekgumbo.com/2011/12/10/setting-the-focus-on-the-google-home-page/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 15:43:48 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4060</guid>
		<description><![CDATA[This is just a quick hitter for those folks that use Firefox as their main browser, and Google as their home page. &#160; I am getting tired of having to reconfigure my system every time we get automatic updates.  A &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/12/10/setting-the-focus-on-the-google-home-page/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is just a quick hitter for those folks that use Firefox as their main browser, and Google as their home page.</p>
<div id="attachment_4063" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox5.5.png"><img class="size-full wp-image-4063" title="tabfirefox5.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox5.5.png" alt="" width="600" height="398" /></a><p class="wp-caption-text">The Problem: the Focus is in the upper URL bar not in the Google Search box in a new Tab window</p></div>
<p>&nbsp;</p>
<p>I am getting tired of having to reconfigure my system every time we get automatic updates.  A couple of months ago, it was Microsoft, in the guise of a security update, adding a browser toolbar that populated new tab windows with the Bing search bar.  That was sneaky, and a sign of things to come.  I wrote <a title="Swapping the Bing Search Bar" href="http://www.geekgumbo.com/2011/09/13/microsoft-swaps-bing-into-your-firefox-search/">an article</a> on how to fix this problem, if you find the Bing search engine popping up in your browsers new tab window.</p>
<p>The next gaff from Microsoft was when they "inadvertently" removed the Chrome browser from your computer in yet another security update. You can <a title="Microsoft removes Chrome" href="http://www.geekgumbo.com/2011/10/01/microsoft-removes-chrome/">read about that one here</a>.</p>
<p>I have VLC loaded to view videos in Firefox.  I recently discovered that Apple changed Firefox to use QuickTime instead of VLC. You can see this, and change it back in Firefox by going to Firefox options in the upper left Firefox icon, and selecting the Applications tab. Scroll down and you'll see Apple's QuickTime on all your video files. If you click the Action setting you can change it back.</p>
<div id="attachment_4065" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox4.5.png"><img class="size-full wp-image-4065" title="tabfirefox4.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox4.5.png" alt="" width="600" height="550" /></a><p class="wp-caption-text">Changing back to VLC instead of Quicktime</p></div>
<p>&nbsp;</p>
<p>The latest annoyance comes from Firefox on their latest browser update.  For those, like me, who have been using Google as their home page for years, instead of those distracting portals, you'll find that when you open a new tab window in Firefox, Google home page will come up, but the focus of where you start typing is in the Firefox's upper URL window, instead of in the Google Home pages search box where it always use to be, see the first picture above.</p>
<p>The problem is when you immediately start typing your search query, it types in the upper URL bar and messes the URL up and doesn't search properly.  Before the focus was on the Google home page's search box when opening a new tab window, and you could start typing immediately.</p>
<p>What this means is when you open a new browser tab window in Firefox, and the Google home page opens, you also have to click in the search box before you start typing your search query.  An extra annoying step.  This is a consistent annoyance for those who are use to just typing their search query as soon as the tab window opens.</p>
<p>If you would like to change it back, in the Firefox top URL window, type "<span style="color: #339966;">about:config</span>" and hit return.  Ignore the warning, and say you'll "be careful" and Firefox config will open.</p>
<p>In the top filter bar, type "<span style="color: #339966;">focus</span>".  I think Firefox knew they may be making a mistake in changing the focus, because the setting you need to change, "<span style="color: #339966;">newtaburl.focus_urlbar</span>" is in bold, hmmm.  Double click anywhere on that line, and the "true" will change to "false" which is what you want. Close the browser and restart it.</p>
<div id="attachment_4067" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox1.5.png"><img class="size-full wp-image-4067" title="tabfirefox1.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox1.5.png" alt="" width="600" height="416" /></a><p class="wp-caption-text">Changing back to the Google Search Bar Focus</p></div>
<p>&nbsp;</p>
<p>Now when you go to a new tab window in Firefox, and your Google home page loads, you'll find you can just start typing, like you use to do, and the search query your typing will be in the Google search bar, not on the top URL bar.  Enjoy.</p>
<div id="attachment_4068" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox3.5.png"><img class="size-full wp-image-4068" title="tabfirefox3.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/tabfirefox3.5.png" alt="" width="600" height="393" /></a><p class="wp-caption-text">All Fixed Up with the focus back in the Google Search Bar</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/12/10/setting-the-focus-on-the-google-home-page/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Changing Eclipse Syntax Colors</title>
		<link>http://www.geekgumbo.com/2011/12/07/changing-eclipse-syntax-colors/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=changing-eclipse-syntax-colors</link>
		<comments>http://www.geekgumbo.com/2011/12/07/changing-eclipse-syntax-colors/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 20:42:21 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[Development Tools]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=4029</guid>
		<description><![CDATA[The Eclipse IDE, as we all know, is like a huge battleship. It's loaded with functionality. Its got a crazy amount of plugins you can load to increase its size, and configure, ugh. It's ancient in some ways, while trying &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/12/07/changing-eclipse-syntax-colors/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Eclipse IDE, as we all know, is like a huge battleship. It's loaded with functionality. Its got a crazy amount of plugins you can load to increase its size, and configure, ugh. It's ancient in some ways, while trying to be modern. It's a big IDE program. My Eclipse folder currently clocks in at 208Mb. That's a big application. In contrast my NetBeans folder clocks in at 144MB. Who says I can't load more than one IDE at a time.</p>
<p>I, like all the rest of you out there who use IDE editors, like color syntax highlighting. It just makes coding so much more pleasurable, and less error prone. And I must admit that I'm forever twiddling with my colors to get them just the way I want them. There always seems to be some color that I just want to make lighter or darker.</p>
<div id="attachment_4032" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse5.5.png"><img class="size-full wp-image-4032" title="eclipse5.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse5.5.png" alt="" width="600" height="705" /></a><p class="wp-caption-text">The Eclipse Changing Color Preference Nightmare</p></div>
<p>&nbsp;</p>
<p>Have you ever tried to change your colors in Eclipse? What a nightmare! If anyone would like to try, go to Window-&gt;Preferences, and there you can configure most anything in Eclipse including plugins. If you want to take a crack at the colors, in the menu search box in the preferences menu, type "color". Where do you start, and more important which setting takes precedence over another setting. I've never figured it out.</p>
<p>There's another problem, which is so exasperating that it's caused me to load NetBeans. Because of all the plugins, each having their own settings, every once in awhile you run into conflicts and collisions. And that's Eclipse's big "Achilles Heel". Conflicts cause crashes, and crashes some times wipe out your workbench, which means you have to reload all your projects and start over, including starting to readjust your colors from the beginning. When it happens in the middle of a big project, you get so frustrated you never want to use Eclipse again, well maybe not that drastic, but as I said, I have loaded NetBeans, which in contrast, is a pleasure to configure.</p>
<p>The Eclipse developers are aware of the problem and have tried to make life simpler, especially for those switching computers, by offering an import and export of your Eclipse preference files. To save your preferences go to File-&gt; Export-&gt; General-&gt; Preferences. This will create an .epf file that you should promptly save to a jump drive for future installations, in case you crash Eclipse and don't want to reconfigure everything. To bring all your settings back, you simply click on File-&gt;Import and load you .epf file.</p>
<p>That's still not the answer to changing your colors, though. Questions like, where do you change that one color that's been bugging you, and should I change any colors, because it might crash my system, come to mind.</p>
<p>I just discovered a plugin that rides to the rescue to save the day, and the dude in distress. The plugin is called the <span style="color: #339966;"><a title="Eclipse Color Theme Plugin" href="http://www.eclipsecolorthemes.org/?view=plugin"><span style="color: #339966;">Eclipse Color Themes Plugin</span></a></span>, and it takes care of your Eclipse Color problems.</p>
<div id="attachment_4051" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse4.51.png"><img class="size-full wp-image-4051" title="eclipse4.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse4.51.png" alt="" width="600" height="484" /></a><p class="wp-caption-text">The Eclipse Color Themes Plugin in Eclipse</p></div>
<p>&nbsp;</p>
<p>The plugin attempts to do three things. First it is the one place, and page, where you can go to adjust your colors, no more 600 windows to search through to adjust that one color.   This alone is a time saver. The second thing it does is change your colors without side effects, that is, crashes and inter-plugin corruption. And lastly, it makes it easy to adjust your colors.</p>
<p>The Color Themes Plugin comes with quite a few color themes installed with the plugin. The "piece de resistance" though is that you can create your own color theme in a nice window on the web site. I created one called "geekgumbo," of course, which anyone is welcome to use. After creating your theme you download the XML file, not the epf file, to your computer, and then import it through the color theme plugin.</p>
<div id="attachment_4035" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse9.5.png"><img class="size-full wp-image-4035" title="eclipse9.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse9.5.png" alt="" width="600" height="392" /></a><p class="wp-caption-text">Creating your own theme on the Color Themes Web Site</p></div>
<p>&nbsp;</p>
<p>The Color Themes configuration preferences in Eclipse are located at "Windows-&gt; Preferences-&gt; General-&gt; Appearance-&gt; Color Theme"  Click on Import a theme, find your custom theme you just downloaded, click "Apply," and presto your colors are your own without any nasty plugin conflict collisions.</p>
<p>Now, you've created your own color theme and you want to do what I like to do, tweak one color. You have a choice. You can do it on the web site, or on your computer. If you go to the web site, click the login link to the right of the page title, login, search for the name of your theme, click on the name of your theme, and your back to the color editor window. Change your colors, download the updated file, import it into the Color Themes plugin preferences in Eclipse, and your up and running.</p>
<div id="attachment_4036" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse8.5.png"><img class="size-full wp-image-4036" title="eclipse8.5" src="http://www.geekgumbo.com/wp-content/uploads/2011/12/eclipse8.5.png" alt="" width="600" height="289" /></a><p class="wp-caption-text">Changing Theme Colors in Eclipse</p></div>
<p>&nbsp;</p>
<p>There's an easier way to do this without going to the web site. The theme file is just an .xml file.  You did download the XML file, didn't you?  Go to the .xml file you downloaded, open it in Eclipse, and edit the colors there.  They will change right away without the download and import.  For those of you that are not sure what the hex color is, or what color you want, I highly recommend a small app called <span style="color: #339966;"><a title="Color Cop" href="http://colorcop.net/"><span style="color: #339966;">ColorCop</span></a></span>, that I've been using for years, and love.  Have fun tweaking your colors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/12/07/changing-eclipse-syntax-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework 2.0.0 Beta 1 Released</title>
		<link>http://www.geekgumbo.com/2011/11/16/zend-framework-2-0-0-beta-1-released/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zend-framework-2-0-0-beta-1-released</link>
		<comments>http://www.geekgumbo.com/2011/11/16/zend-framework-2-0-0-beta-1-released/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 13:34:33 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[PHP Frameworks]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=3935</guid>
		<description><![CDATA[The most anticipated PHP framework in a number of years, the Zend Framework 2.0 is on track for release in early 2012.  This beta release is the first in a series of beta releases that will happen approximately every six &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/11/16/zend-framework-2-0-0-beta-1-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.geekgumbo.com/wp-content/uploads/2011/11/zf25.png"><img class="alignleft size-full wp-image-3937" title="zf25" src="http://www.geekgumbo.com/wp-content/uploads/2011/11/zf25.png" alt="" width="300" height="157" /></a>The most anticipated PHP framework in a number of years, the Zend Framework 2.0 is on track for release in early 2012.  This beta release is the first in a series of beta releases that will happen approximately every six weeks.  When the code becomes stable the new framework will move to Release Candidate status just prior to release.</p>
<p>The first Zend Framework has been used by independent and corporate developers with larger development teams ever since it was first announced in December 2007.</p>
<p>As time went on more and more open source PHP frameworks became available to compete with the Zend framework, while the Zend framework added more functionality, became larger, and gradually slowed down.  The newer frameworks were less functional, but considerably faster.</p>
<p>PHP gradually moved to object oriented coding and added namespaces in PHP 5.3. New impovements and changes to PHP itself were not able to be easily incorporated into the first Zend framework.</p>
<p>The result was an outdated framework that was slower than the newer frameworks available. It was time for an upgrade.</p>
<p>The goals of Zend Framework 2 were to be considerably faster in the range of the faster PHP frameworks, to make the Zend framework much easier to learn, to be easier to use only what you needed, to be easier to extend for adding new modulues, and to use PHP 5.3 functionality through out the code base.</p>
<p>Much of the code that slowed the framework down has been refactored.  This first Beta release features an updated autoloader with StandardAutoloader, ClassMapAutoloader, and AutoLoad Factory.  A new plugin broker strategy, a refactored routing system, a reworked Exception system to allow catching by exception type, a rewritten session component, refactored View and HTTP components, a new cloud infrastructure component, a scanner component, and a new annotation system.  Finally a Module component for developing modular applications, and a completely reworked MVC layer built on top of an event manager.</p>
<p>They even included a skeleton application and quick start documentation with the Beta to get you started.  That should get your mouth watering, and if it does, you're a true geek.  Forget the wife or  girlfriend, and wrap your head around this puppy.  If you'd like to download the Beta release you can get it from the new <a title="Zend Framework 2 Packages" href="http://packages.zendframework.com/">Zend Framework 2 Packages</a> website, have fun, and help the community get it right.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/11/16/zend-framework-2-0-0-beta-1-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Modulus Operator</title>
		<link>http://www.geekgumbo.com/2011/08/16/the-modulus-operator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-modulus-operator</link>
		<comments>http://www.geekgumbo.com/2011/08/16/the-modulus-operator/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 14:21:27 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=3387</guid>
		<description><![CDATA[I was looking through my JavaScript operators the other day and came across the modulus operator.  The modulus operator is used in almost all programming languages, and usually it is represented by a "%" sign.  It performs what is called &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/08/16/the-modulus-operator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was looking through my JavaScript operators the other day and came across the modulus operator.  The modulus operator is used in almost all programming languages, and usually it is represented by a "%" sign.  It performs what is called the modulo operation.</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddeven45.jpg"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddeven45.jpg" alt="" title="oddeven45" width="600" height="219" class="aligncenter size-full wp-image-3405" /></a></p>
<p>OK, now that I've thrown that at you, how do you use it, what does it do, and of what use is it?</p>
<p>First let's show how its used.  In JavaScript it looks like this:<br />
var result = 14 % 2 ;<br />
The value of "result" is 0 .</p>
<p>And in PHP it looks like this:<br />
$theresult = 15 % 2 ;<br />
The value of "$theresult" is 1 .</p>
<p>a % b is pronounced "a modulo b" where a is the dividend, and b is the divisor.</p>
<p>Not much difference in the two languages syntax, and in fact, it is used with the same syntax in all the web programming languages, such as: ActionScript, C, ColdFusion, Java, JavaScript, Perl, PHP, Python, Ruby, and Tcl.</p>
<p>What does it do?  It gives you the remainder of a division.  In the JavaScript example, 14/2 = 7 with no remainder left over, so the modulo of 14 % 2 = 0.  There is no remainder.  In the PHP example, we have 15/2  = 7 with 1 left over.  So 15 % 2 = 1 since we have a remainder of 1.  Pretty simple.</p>
<p>We can use other numbers than 2 as our divisor.<br />
15 % 4  = 3  The nearest number with no remainder is 12.  15-12 gives us 3.</p>
<p>What happens when you have a minus sign in the divisor?<br />
13 % -4 = 1<br />
The answer always takes the sign of the dividend. So,<br />
-13 % 4 = -1</p>
<p>We can use the modulo with other math operations.<br />
22 % ( 9 + 2) = 0</p>
<p>What if the divisor is bigger then the dividend?  Then the value of the modulo is the same as the dividend.<br />
12 % 16 = 12</p>
<p>What about floats?<br />
0.5 % 0.3 = 0.2</p>
<p>This will work fine with JavaScript, as both integers and floats are the same number data type in JavaScript, but with languages like PHP, that have integers and floats as separate data types, it will not.</p>
<p>PHP has a separate function to do floating modulo, fmod(), like so:</p>
<pre class="brush:php">
$a = 5.7;
$b = 1.3;
$theFloatMod = fmod($a, $b);
or
$theFloatMod = fmod( 5.7, 1.3)
//The answer
$theFloatMod = 0.5;
</pre>
<p>Of course, for integers, PHP uses the same syntax as JavaScript.</p>
<p>Before talking about what the modulo is used for, let's go over the range of possible modulo answers.  If we have $c = $a % $b, then:<br />
1. If $b goes evenly into $a, then we know $c = 0.<br />
2. If $b is bigger than $a, then we know $c = $a.<br />
3. Finally, the way its normally used, where $a is bigger than $b.  The answer will be between $b-1 and 1.</p>
<p>Now, the big question, what's it used for? </p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddandeven25.jpg"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddandeven25.jpg" alt="" title="oddandeven25" width="400" height="203" class="aligncenter size-full wp-image-3407" /></a>   </p>
<p>Well, we can find the number of 10's, 100's, or 1,000's in a number.  It goes something like this for 10's.</p>
<pre class="brush:php">
$answer = ($theNumber - ($theNumber % 10))/10;

//Let's work an example
$theNumber = 92;
$answer = (92 - (92 % 10))/10 = (92 - 2)/10 = 9

// For 100's the formula would be:
$answer = ($theNumber - ($theNumber % 100))/100;
</pre>
<p>If we are iterating through an array repeatedly to put a grid on the screen, for example, the modulo operator can be used to determine the end of the array, and reset to the beginning index value by using the maximum number of the array, like so: ( (i++) % maxArrayDimension)</p>
<p><a href="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddeven2.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/08/oddeven2.png" alt="" title="oddeven2" width="400" height="222" class="aligncenter size-full wp-image-3406" /></a></p>
<p>Finally, the main use of the operator is to determine if a number is odd or even, as we did above.  If you divide any number by 2 and it comes up with a modulo of "0", it's an even number.  If it comes up with a "1", it's an odd number.  We then can use this in a conditional statement, and do something with it, for example, a table row, if it's an odd row, we could change the background color of the row for easier reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/08/16/the-modulus-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS with a little Class</title>
		<link>http://www.geekgumbo.com/2011/07/29/css-with-a-little-class-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-with-a-little-class-2</link>
		<comments>http://www.geekgumbo.com/2011/07/29/css-with-a-little-class-2/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 14:27:45 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=3327</guid>
		<description><![CDATA[I couldn't help myself with the title. In a previous post we talked about using class a little more often than ID's, and I thought I'd expand on the class tag a little more. The class tag in HTML is &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/07/29/css-with-a-little-class-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I couldn't help myself with the title.  In a previous post we talked about using class a little more often than ID's, and I thought I'd expand on the class tag a little more.  </p>
<p>The class tag in HTML is used to define different sections of the web page that you want to look the same, so you can later style those sections of the page with CSS or JavaScript.  </p>
<p>For example, it can be used to make all the numbers on a page look bigger, or it could be used across several pages to identify different specific parts of your page that you would like to look the same on every page of your web site.</p>
<p>The class attribute looks something like this:</p>
<pre class="brush:html">
In a div:
<div class="harry">
.... something goes here ....
</div>

And inline:
The quick brown <span class="fox">fox</span> jumped over the lazy dog.
</pre>
<p>You can put a class attribute on any html tag.  You'll noticed I put a slash ending on each HTML tag, in addition to, making it HTML5 compatible, it also defines the end of the class.  </p>
<p>One problem you may have in your CSS styling is caused by not ending HTML tags.  This is one of the reasons you should always validate both your HTML and CSS scripts.  Validating will pick up where you missed those nasty end tags, and make sure you haven't missed any ":" or  ";" in your CSS script.</p>
<p>Let's get into some unique things we can do with the class attribute. You can combine class and id attributes in a single tag.  The ID tag is the unique name of a section of the page, and that name can only be used once on the page.  Here's an example of an ID and CLASS tags together:</p>
<pre class="brush:html">
In a div:
<div class="names" id="tom">
.... something tomish goes here ....
</div>
<div class="names" id="dick">
.... something dickish goes here ....
</div>
<div class="names" id="harry">
.... something harryish goes here ....
</div>
</pre>
<p>To use this in your CSS script, we could do something like:</p>
<pre class="brush:html">
.names {
font-weight: 800;
font-decoration: underline;
font-size: 1.2em;
}

#tom {
color: blue;
}

#dick {
color: green;
}

#harry {
color: magenta;
}

And you can combine them like so:
#tom.names {
font-style: italic;
}

.names#tom {
font-style: oblique;
}
</pre>
<p>In the case of the last two tags where we combined the ID and CLASS attributes, both are identical, and the order of the tags does not matter.  You can have the ID first or the CLASS first, it is the same and has the same weight in CSS.  </p>
<p>In this case since ".names#tom" is last in the script, the font-style rendered on the page will have the oblique font-style, thanks to the CSS cascade.</p>
<p>As long as we're talking about combining tags, you can have more than one class attribute in a single tag. Let's take a look at how this is done:</p>
<pre class="brush:html">
<div class="names places events caramel fudge syrup">
... something goes here ...
</div>
</pre>
<p>All the class names above are valid class names. </p>
<p>Let's take a closer look. You can have as many class names  as you want in between the class quotes.  Each class name is separated by a space, not a comma.  The order the class names are in does not matter.  The classes "names fudge" is the same as "fudge names" in the eyes of CSS.</p>
<p>Here's an example where we use the same styling as in our first example, using classes instead of the id's in the first example.  The styling on the web page will be the same as in the first example.</p>
<pre class="brush:html">
.names {
font-weight: 800;
font-decoration: underline;
font-size: 1.2em;
}

.tom {
color: blue;
}

.dick {
color: green;
}

.harry {
color: magenta;
}

And you can combine them like so:
.tom.names {
font-style: italic;
}

.names.tom {
font-style: oblique;
}
</pre>
<p>The order of the names does not matter.  The result will be an oblique font-style for .tom.names because of the CSS cascade. Also you can push the CSS name together, and don't need a space to separate them in the CSS tag.</p>
<p>One final note, for the few of you that still use IE6.  IE6 does not do multiclassing. If you have CSS tags like ".names.tom", it will only see the last class name ".tom".  You can still use each class in separate tags though, so ".names" works as a stand alone CSS tag. </p>
<p>Gee, I hope if your reading this post, none of you are using IE6, in fact I hope none of you are using any IE for your web development. If so, I'd like to suggest you might be a tad behind the technical power curve.  Until next time...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/07/29/css-with-a-little-class-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Sorting and Renumbering Array Keys</title>
		<link>http://www.geekgumbo.com/2011/07/22/php-sorting-and-renumbering-array-keys/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-sorting-and-renumbering-array-keys</link>
		<comments>http://www.geekgumbo.com/2011/07/22/php-sorting-and-renumbering-array-keys/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 12:27:26 +0000</pubDate>
		<dc:creator>daleV</dc:creator>
				<category><![CDATA[Sorting Arrays]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=3276</guid>
		<description><![CDATA[In a previous article I covered sorting arrays when you need to maintain key-value relationships. There are times when your interested in sorting array values, and then have the array keys match the sort. There are three array sorts you &#8230; <a class="more-link" href="http://www.geekgumbo.com/2011/07/22/php-sorting-and-renumbering-array-keys/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In a previous article I covered sorting arrays when you need to maintain key-value relationships.  There are times when your interested in sorting array values, and then have the array keys match the sort.  There are three array sorts you can use for this: sort, rsort, and shuffle.</p>
<p>Let's create a test array, $testarray, we'll work with when looking at the sorts.  I've tried to mix it up with upper case, lower case, and numbers to sort. Here's the array before any sorting is done.</p>
<div id="attachment_3278" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-none5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-none5.png" alt="" title="sortnk-none5" width="600" height="192" class="size-full wp-image-3278" /></a><p class="wp-caption-text">The $testarray unsorted</p></div>
<p></p>
<h2 style="text-align: center;"><span style="text-decoration: underline;"><em><strong>SORT</strong></em></span></h2>
<p>Sort sorts an array from the lowest value to the highest value, and reassigns the keys to match the sort.   </p>
<pre class="brush:php">
sort($testarray);
</pre>
<p>Here what the array looks like after the sort:</p>
<div id="attachment_3279" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-sort5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-sort5.png" alt="" title="sortnk-sort5" width="600" height="190" class="size-full wp-image-3279" /></a><p class="wp-caption-text">sort($testarray)</p></div>
<p>Notice the keys have been relabeled starting at 0, and incrementing by 1 for each field.  You might use this in a drop-down menu with a set array that will never change values.</p>
<p>Sort has some optional second parameters that you can use to change the sort: SORT_REGULAR, which is the same as just using sort(); SORT_NUMERIC, which compares values numerically; SORT_STRING, which compares values as strings; and SORT_LOCAL_STRING, which sorts values as strings depending on your locality.  They are used like so:</p>
<pre class="brush:php">
sort($testarray, SORT_NUMERIC )
</pre>
<p>And here's the result:</p>
<div id="attachment_3280" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-numeric5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-numeric5.png" alt="" title="sortnk-numeric5" width="600" height="193" class="size-full wp-image-3280" /></a><p class="wp-caption-text">sort($testarray, SORT_NUMERIC)</p></div>
<p>You'll notice the numbers are sorted, but not the strings<br />
Let's try the sort with the sort_string parameter:</p>
<pre class="brush:php">
sort($testarray, SORT_STRING)
</pre>
<div id="attachment_3283" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-string5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-string5.png" alt="" title="sortnk-string5" width="600" height="190" class="size-full wp-image-3283" /></a><p class="wp-caption-text">sort($testarray, SORT_STRING)</p></div>
<p>Here the strings are sorted, but the numbers are not.</p>
<p>++++++++++++++++++++++++++++++++++++++</p>
<p></p>
<h2 style="text-align: center;"><span style="text-decoration: underline;"><em><strong>RSORT</strong></em></span></h2>
<p>Rsort is the same as sort only it sorts in the reverse order. You can use the same second parameter you used in sort() with rsort().</p>
<p>Here's the call:</p>
<pre class="brush:php">
rsort($testarray)
</pre>
<p>And here's the results:</p>
<div id="attachment_3290" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsort5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsort5.png" alt="" title="sortnk-rsort5" width="600" height="196" class="size-full wp-image-3290" /></a><p class="wp-caption-text">rsort($testarray)</p></div>
<p>If you use the second parameter, you can sort just the numbers or strings in reverse order.</p>
<p>Here's the numbers with:</p>
<pre class="brush:php">
rsort($testarray, SORT_NUMERIC)
</pre>
<p>Again, note the strings are not sorted, but the numbers are.</p>
<div id="attachment_3291" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsortnum5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsortnum5.png" alt="" title="sortnk-rsortnum5" width="600" height="192" class="size-full wp-image-3291" /></a><p class="wp-caption-text">rsort($testarray, SORT_NUMERIC)</p></div>
<p>Here's rsort with the string.</p>
<pre class="brush:php">
rsort($testarray, SORT_STRING)
</pre>
<p>An with the strings reverse sorted, but not the numbers it looks like this:</p>
<div id="attachment_3292" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsortstr5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-rsortstr5.png" alt="" title="sortnk-rsortstr5" width="600" height="193" class="size-full wp-image-3292" /></a><p class="wp-caption-text">rsort($testarray, SORT_STRING)</p></div>
<p>++++++++++++++++++++++++++++++++++++++</p>
<p></p>
<h2 style="text-align: center;"><span style="text-decoration: underline;"><em><strong>SHUFFLE</strong></em></span></h2>
<p>Let's move to our final sort, shuffle, that renumbers the keys.  It goes like so:</p>
<pre class="brush:php">
shuffle($testarray)
</pre>
<p>This does exactly what the word says, it shuffles the values in the array and reassigns the keys.  You might want to use this if you have a large array and our testing against varies values that you want to look at randomly.</p>
<p>Here's what the output looks like:</p>
<div id="attachment_3293" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-shuffle5.png"><img src="http://www.geekgumbo.com/wp-content/uploads/2011/07/sortnk-shuffle5.png" alt="" title="sortnk-shuffle5" width="600" height="196" class="size-full wp-image-3293" /></a><p class="wp-caption-text">shuffle($testarray)</p></div>
<p>There's not to much more to say about shuffle.</p>
<p>If you like the way the arrays appear in this article, I do this with chk.php.  You can download the utility program for free at <a href="http://www.newchk.com/" title="New Chk Utility">www.newchk.com</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2011/07/22/php-sorting-and-renumbering-array-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

