<?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>cnicollonline &#187; Notes</title>
	<atom:link href="http://cnicollonline.com/category/notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://cnicollonline.com</link>
	<description>&#34;I was just guessing at numbers and figures, pulling the puzzles apart&#34;</description>
	<lastBuildDate>Mon, 23 Aug 2010 19:16:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Arrays and Loops with php [Level 2]</title>
		<link>http://cnicollonline.com/programming/arrays-and-loops-with-php-level-2/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://cnicollonline.com/programming/arrays-and-loops-with-php-level-2/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 18:27:01 +0000</pubDate>
		<dc:creator>Cosizzle</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[multidimensional arrays]]></category>

		<guid isPermaLink="false">http://cnicollonline.com/?p=204</guid>
		<description><![CDATA[A few weeks ago I had wrote Arrays and Loops with php [Level 1]. This topic is expanding on that idea. I&#8217;ll be covering more complex array examples using 2D multidimensional&#160;arrays. Multidimensional&#160;Arrays The idea of a multidimensional array is something that can easily confuse someone, especially when they become complex with information (ie. 2D and [...]]]></description>
			<content:encoded><![CDATA[<p><!--<br />
- WORDPRESS TEMPLATE FOR CREATING OR POSTING TO MY BLOG.<br />
- COMMON TAGS TO&nbsp;NOTE:</p>
<p>-<br />
<h2>MAIN&nbsp;TITLE</h2>
<p>-<br />
<h3></h3>
<p>-<br />
<h4></h4>
<p>-
<ul>
<li>LIST&nbsp;ITEM</li>
</ul>
<p>-
<ol>
<li>ORDER LIST&nbsp;ITEM</li>
</ol>
<p>- adding a download link<br />
<a href="http://www.cnicollonline.com/wp-articles/PATH TO LINK" target="_self">click&nbsp;here</a></p>
<p>- adding an&nbsp;image</p>
<div class="tutorial_image"><img src="http://www.cnicollonline.com/wp-articles/PATH TO IMG/1.jpg" border="0" /></div>
<p>--></p>
<p>A few weeks ago I had wrote <a href="http://cnicollonline.com/?p=186#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_self">Arrays and Loops with php [Level 1].</a> This topic is expanding on that idea. I&#8217;ll be covering more complex array examples using 2D multidimensional&nbsp;arrays.</p>
<p><span id="more-204"></span></p>
<h3>Multidimensional&nbsp;Arrays</h3>
<p>The idea of a multidimensional array is something that can easily confuse someone, especially when they become complex with information (ie. 2D and 3D arrays). I like to think of multidimensional arrays as a miniature&nbsp;database.</p>
<p>A multidimensional array can hold multiple values to a single key. Take a look at the output&nbsp;below.</p>
<pre>Array
(
    [0] => Array
        (
            [name] => Cody
            [gender] => male
            [colour] => green
            [fruit] => apples
            [sport] => frisbee
        )

    [1] => Array
        (
            [name] => Sam
            [gender] => male
            [colour] => blue
            [fruit] => oranges
            [sport] => golf
        )

    [2] => Array
        (
            [name] => Jenny
            [gender] => female
            [colour] => pink
            [fruit] => pineapple
            [sport] => hockey
        )

)
</pre>
<p>This example is an example of a 2D array using key values. By default PHP will auto fill the keys, but this can lead to confusion down the road. To set up the&nbsp;array: </p>
<pre class="brush: php;">
$people = array( array(&quot;name&quot;=&gt;&quot;Cody&quot;,
						&quot;gender&quot;=&gt;&quot;male&quot;,
						&quot;colour&quot;=&gt;&quot;green&quot;,
						&quot;fruit&quot;=&gt;&quot;apples&quot;,
						&quot;sport&quot;=&gt;&quot;frisbee&quot;),
				array(&quot;name&quot;=&gt;&quot;Sam&quot;,
					&quot;gender&quot;=&gt;&quot;male&quot;,
						&quot;colour&quot;=&gt;&quot;blue&quot;,
						&quot;fruit&quot;=&gt;&quot;oranges&quot;,
						&quot;sport&quot;=&gt;&quot;golf&quot;),
				array(&quot;name&quot;=&gt;&quot;Jenny&quot;,
						&quot;gender&quot;=&gt;&quot;female&quot;,
						&quot;colour&quot;=&gt;&quot;pink&quot;,
						&quot;fruit&quot;=&gt;&quot;pineapple&quot;,
						&quot;sport&quot;=&gt;&quot;hockey&quot;)
				);

echo '&lt;pre&gt;';
	print_r($people);
echo '&lt;/pre&gt;';
</pre>
<p>There&#8217;s a lot going on, take some time and read through it. First we set up a main container that will hold all of our information
<pre>$people</pre>
<p> we then put a new array within our already created&nbsp;array.</p>
<p>Retrieving a single value is quite easy. We just call on what array element we want, then we ask for a specific property, in this example the&nbsp;name.</p>
<pre class="brush: php;">
echo '&lt;pre&gt;';
echo $people[0]['name'];
echo '&lt;/pre&gt;';
</pre>
<h3>How this can be&nbsp;used</h3>
<p>By looping of course! We can loop through this in many different ways to provide an&nbsp;example:</p>
<pre class="brush: php;">
for ($i=0; $i&lt;sizeOf($people); $i++) {
	$string = $people[$i]['name'] . &quot;'s favorite fruit is &quot; . $people[$i]['fruit'];
	if ($people[$i]['gender'] === &quot;male&quot;) {
		$string .= &quot; his favorite colour is &quot; . $people[$i]['colour'] . &quot; and he enjoys to play &quot; . $people[$i]['sport'];
	}
	else if ($people[$i]['gender'] === &quot;female&quot;) {
		$string .= &quot; her favorite colour is &quot; . $people[$i]['colour'] . &quot; and she enjoys to play &quot; . $people[$i]['sport'];
	}
	echo $string;
	echo '&lt;br&gt;';
}
</pre>
<p>output:</p>
<pre>
Cody's favorite fruit is apple his favorite colour is green and he enjoys to play frisbee
Sam's favorite fruit is oranges his favorite colour is blue and he enjoys to play golf
Jenny's favorite fruit is pineapple her favorite colour is pink and she enjoys to play hockey
</pre>
<p>Here I used a if statement within my for loop to check the gender value. If it were a male I had the output specify &#8220;he&#8221;, and the same check for a&nbsp;female.</p>
<p>Another use for a multidimensional array is a table layout, or&nbsp;grid.</p>
<pre class="brush: php;">
$grid = array(array('Cody','male','green'),
			array('Sam','male','blue'),
			array('Jenny', 'female','pink')
);
for ($r=0; $r&lt;sizeOf($grid); $r++) {
	for($c=0; $c&lt;sizeOf($grid[$r]); $c++) {
		echo $grid[$r][$c]. &quot; | &quot;;
	}
	echo '&lt;br&gt;';
}
</pre>
<p>output:</p>
<pre>
Cody | male | green |
Sam | male | blue |
Jenny | female | pink |
</pre>
<h3>Conclusion</h3>
<p>multidimensional arrays make for an interesting topic, there is so much you can do, but without doing they can be hard to explain. Here is the source to help you get&nbsp;started.</p>
<pre class="brush: php; collapse: true; light: false; toolbar: true;">
&lt;?php
$people = array( array(&quot;name&quot;=&gt;&quot;Cody&quot;,
						&quot;gender&quot;=&gt;&quot;male&quot;,
						&quot;colour&quot;=&gt;&quot;green&quot;,
						&quot;fruit&quot;=&gt;&quot;apples&quot;,
						&quot;sport&quot;=&gt;&quot;frisbee&quot;),
				array(&quot;name&quot;=&gt;&quot;Sam&quot;,
					&quot;gender&quot;=&gt;&quot;male&quot;,
						&quot;colour&quot;=&gt;&quot;blue&quot;,
						&quot;fruit&quot;=&gt;&quot;oranges&quot;,
						&quot;sport&quot;=&gt;&quot;golf&quot;),
				array(&quot;name&quot;=&gt;&quot;Jenny&quot;,
						&quot;gender&quot;=&gt;&quot;female&quot;,
						&quot;colour&quot;=&gt;&quot;pink&quot;,
						&quot;fruit&quot;=&gt;&quot;pineapple&quot;,
						&quot;sport&quot;=&gt;&quot;hockey&quot;)
				);

echo '&lt;pre&gt;';
	print_r($people);
echo '&lt;/pre&gt;';

// Get a single value
echo '&lt;pre&gt;';
echo $people[0]['name'];
echo '&lt;/pre&gt;';
// ================================================= LOOP =================================================
for ($i=0; $i&lt;sizeOf($people); $i++) {
	$string = $people[$i]['name'] . &quot;'s favorite fruit is &quot; . $people[$i]['fruit'];
	if ($people[$i]['gender'] === &quot;male&quot;) {
		$string .= &quot; his favorite colour is &quot; . $people[$i]['colour'] . &quot; and he enjoys to play &quot; . $people[$i]['sport'];
	}
	else if ($people[$i]['gender'] === &quot;female&quot;) {
		$string .= &quot; her favorite colour is &quot; . $people[$i]['colour'] . &quot; and she enjoys to play &quot; . $people[$i]['sport'];
	}
	echo $string;
	echo '&lt;br&gt;';
}

// ================================================= GRID =================================================
$grid = array(array('Cody','male','green'),
			array('Sam','male','blue'),
			array('Jenny', 'female','pink')
);
for ($r=0; $r&lt;sizeOf($grid); $r++) {
	for($c=0; $c&lt;sizeOf($grid[$r]); $c++) {
		echo $grid[$r][$c]. &quot; | &quot;;
	}
	echo '&lt;br&gt;';
}

?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cnicollonline.com/programming/arrays-and-loops-with-php-level-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Phone Validation</title>
		<link>http://cnicollonline.com/programming/phone-validation/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://cnicollonline.com/programming/phone-validation/#comments</comments>
		<pubDate>Thu, 14 May 2009 17:06:50 +0000</pubDate>
		<dc:creator>Cosizzle</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippits]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[phone]]></category>

		<guid isPermaLink="false">http://cnicollonline.com/?p=174</guid>
		<description><![CDATA[I tend to do a lot of work with database entry through PHP forums. Over time I&#8217;ve seen nemorous ways in which someone will enter their phone&#160;number. The&#160;Problem Because there are so many different ways to enter a phone number. How it&#8217;s handled, processed and sent to the database becomes a challenge, and as a [...]]]></description>
			<content:encoded><![CDATA[<!--
- WORDPRESS TEMPLATE FOR CREATING OR POSTING TO MY BLOG.
- COMMON TAGS TO NOTE:

- <h2>MAIN TITLE</h2>
- <h3></h3>
- <h4></h4>

- <ul><li>LIST ITEM</li></ul>

- <ol><li>ORDER LIST ITEM</li></ol>

- adding a download link
<a href="http://www.cnicollonline.com/wp-articles/PATH TO LINK" target="_self">click here</a>

- adding an image
<div class="tutorial_image"><img src="http://www.cnicollonline.com/wp-articles/PATH TO IMG/1.jpg" border="0" /></div>
-->

<p>I tend to do a lot of work with database entry through PHP forums. Over time I've seen nemorous ways in which someone will enter their phone number.</p>

<span id="more-174"></span>

<h2>The Problem</h2>
<p>Because there are so many different ways to enter a phone number. How it's handled, processed and sent to the database becomes a challenge, and as a programmer you have to ask "what is the best way".</p>
<h2>The Solution</h2>
<p><p>The first solution would be to make your column in which will hold the phone number within your database a varchar(20). I suppose for something quick and dirty it will work, but in no means is this efficient.</p>
<p>The second solution would be to take a number:</p>
<ul>
	<li>(555)555-5555</li>
	<li>555.555.5555</li>
	<li>555 555 5555</li>
	<li>55 55  55 5555</li>
</ul>
<p>and remove unneeded characters and insert it into the database as a int value of 5555555555</p></p>
<p>The class:</p>
[php]
<br />
<b>Fatal error</b>:  Cannot redeclare class PhoneValidate in <b>/home/cnicollo/public_html/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()'d code</b> on line <b>51</b><br />

