<?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; Snippits</title>
	<atom:link href="http://cnicollonline.com/category/programming/snips/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>Class: File Details released</title>
		<link>http://cnicollonline.com/programming/class-file-details-released/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://cnicollonline.com/programming/class-file-details-released/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 19:41:16 +0000</pubDate>
		<dc:creator>Cosizzle</dc:creator>
				<category><![CDATA[Class]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippits]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://cnicollonline.com/?p=209</guid>
		<description><![CDATA[I was tasked with a project at work in which I had to build a site that would be quite dynamic. The problem however was that I could not use a database to hold information. What I did (and something I would avoid if I could) was create a class that looks within a folder [...]]]></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>06-15-09_00-00_fileDetails<br />
-
<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>I was tasked with a project at work in which I had to build a site that would be quite dynamic. The problem however was that I could not use a database to hold information. What I did (and something I would avoid if I could) was create a class that looks within a folder thats specified and builds an array off the files within the&nbsp;folder.</p>
<p><span id="more-209"></span></p>
<h3>How it&nbsp;works</h3>
<p>Reads a folder of files, breaks apart the file name by a specified &#8220;breaker&#8221;. It then creates a new array off the specified file name&nbsp;attributes</p>
<div class="tutorial_image"><img src="http://www.cnicollonline.com/wp-articles/06-15-09_00-00_fileDetails/fileInfo.jpg" border="0" /></div>
<h3>Demo</h3>
<p>File&nbsp;setup:</p>
<pre class="brush: php;">
include_once('FileDetail.class.php');
// a new object reference using an array for the parameter which specifies the file name attributes
// FileDetail(array(attributes));
$files = new FileDetail(array('id','movie','name','ext'));

// loadFiles(Folder, separator)
$files-&gt;loadFiles('test_files2','_');

// New variable to hold the file name array
$fileNames = $files-&gt;getFileNames();

// New Variable to hold the file details array
$fileDetails = $files-&gt;getFileDetails();
</pre>
<p>Testing the&nbsp;arrays:</p>
<pre class="brush: php;">
// ========================================= EXAMPLE =========================================
echo '&lt;h4&gt;File Names Test 2&lt;/h4&gt;';
echo '&lt;pre&gt;';
	print_r($fileNames);
echo '&lt;/pre&gt;';

// ========================================= EXAMPLE =========================================
echo '&lt;h4&gt;File Details&lt;/h4&gt;';
echo '&lt;pre&gt;';
	print_r($fileDetails);
echo '&lt;/pre&gt;';
</pre>
<p><strong>File&nbsp;Names</strong></p>
<pre>
Array
(
    [0] => 01_wall-e_walle02.jpg
    [1] => 02_batman_joker02.jpg
    [2] => 02_wall-e_walle.jpg
    [3] => 04_batman_joker02.jpg
    [4] => 05_batman_joker.jpg
)
</pre>
<p><strong>File&nbsp;Details</strong></p>
<pre>
Array
(
    [0] => Array
        (
            [id] => 01
            [movie] => wall-e
            [name] => walle02
            [ext] => jpg
        )

    [1] => Array
        (
            [id] => 02
            [movie] => batman
            [name] => joker02
            [ext] => jpg
        )

    [2] => Array
        (
            [id] => 02
            [movie] => wall-e
            [name] => walle
            [ext] => jpg
        )

    [3] => Array
        (
            [id] => 04
            [movie] => batman
            [name] => joker02
            [ext] => jpg
        )

    [4] => Array
        (
            [id] => 05
            [movie] => batman
            [name] => joker
            [ext] => jpg
        )

)
</pre>
<p>Real World&nbsp;Example:</p>
<pre class="brush: php;">
echo '&lt;h4&gt;Get files of a specific parameter&lt;/h4&gt;';
echo '&lt;h5&gt; movie -&gt; batman&lt;/h5&gt;';
echo '&lt;pre&gt;';
	print_r($files-&gt;getFilesByKey('movie','batman'));
echo '&lt;/pre&gt;';
</pre>
<p><strong>Get files of a specific parameter (movies->batman)</strong></p>
<pre>
Array
(
    [0] => Array
        (
            [id] => 02
            [movie] => batman
            [name] => joker02
            [ext] => jpg
        )

    [1] => Array
        (
            [id] => 04
            [movie] => batman
            [name] => joker02
            [ext] => jpg
        )

    [2] => Array
        (
            [id] => 05
            [movie] => batman
            [name] => joker
            [ext] => jpg
        )

)
</pre>
<h3>Conclusion</h3>
<p>The class can be used in many which ways whether it&#8217;s loading a gallery of images or building a website based off of the attributes of the images. The class and demo files can be downloaded&nbsp;<a href="http://www.cnicollonline.com/wp-articles/06-15-09_00-00_fileDetails/fileDetails.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cnicollonline.com/programming/class-file-details-released/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 />

