<?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>nhaskins.com &#187; php</title>
	<atom:link href="http://nhaskins.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://nhaskins.com</link>
	<description>web development note book</description>
	<lastBuildDate>Mon, 06 Feb 2012 02:44:00 +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>moving data from php to javascript: static includes</title>
		<link>http://nhaskins.com/post/moving-data-from-php-to-javascript-static-includes/</link>
		<comments>http://nhaskins.com/post/moving-data-from-php-to-javascript-static-includes/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 02:32:28 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nhaskins.com/post/moving-data-from-php-to-javascript-static-includes/</guid>
		<description><![CDATA[research into including php generated html into javascript for ajax dom updates. yea&#8230; its all about removing the \n &#8216;s from the human readable markup. im trying to get it so i can edit one nice html template, and have php insert the data, and then minify it for javascript, so javascript can add it [...]]]></description>
			<content:encoded><![CDATA[<p>research into including php generated html into javascript for ajax dom updates.  </p>
<p>yea&#8230; its all about removing the \n &#8216;s from the human readable markup. im trying to get it so i can edit one nice html template, and have php insert the data, and then minify it for javascript, so javascript can add it to the page at whim.  so many buzz words.</p>
<p>much more research needs to be done into further stress testing the minify function, although it currently accept quite a bit.also need to work on a function to merge the human readable html template with mysql data&#8230; it does that, then calls minify, then hands it back to javascript initially as an inline variable, and later as json.  I need to get it so i have nice clean template with variable holders&#8230;.dry as possible.<a href="http://nhaskins.com/wp-content/uploads/2010/10/moving_data_from_php_to_js1.png" rel="lightbox[891]"><img src="http://nhaskins.com/wp-content/uploads/2010/10/moving_data_from_php_to_js1.png" alt="" title="moving_data_from_php_to_js" width="677" height="924" class="aligncenter size-full wp-image-890" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/post/moving-data-from-php-to-javascript-static-includes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php parse csv files into mysql commands</title>
		<link>http://nhaskins.com/post/php-parse-csv-files-into-mysql-commands/</link>
		<comments>http://nhaskins.com/post/php-parse-csv-files-into-mysql-commands/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 18:34:29 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nhaskins.com/post/php-parse-csv-files-into-mysql-commands/</guid>
		<description><![CDATA[A quick script to take a .csv file, and generate some insert commands into mysql. The client hands me a spread sheet file, i drop it into a folder and run the script pretty easy.]]></description>
			<content:encoded><![CDATA[<p>A quick script to take a .csv file, and generate some insert commands into mysql.  The client hands me a spread sheet file, i drop it into a folder and run the script pretty easy.</p>
<div id="attachment_855" class="wp-caption aligncenter" style="width: 459px"><a href="http://nhaskins.com/wp-content/uploads/2010/09/Screen-shot-2010-09-30-at-1.31.45-PM.png" rel="lightbox[856]"><img src="http://nhaskins.com/wp-content/uploads/2010/09/Screen-shot-2010-09-30-at-1.31.45-PM.png" alt="" title="Screen shot 2010-09-30 at 1.31.45 PM" width="449" height="764" class="size-full wp-image-855" /></a><p class="wp-caption-text">add one csv file, and run.</p></div>]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/post/php-parse-csv-files-into-mysql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I just got owned by losing my global var&#8230;</title>
		<link>http://nhaskins.com/status/i-just-got-owned-by-losing-my-global-var/</link>
		<comments>http://nhaskins.com/status/i-just-got-owned-by-losing-my-global-var/#comments</comments>
		<pubDate>Wed, 19 May 2010 16:14:45 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[status]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nhaskins.com/status/i-just-got-owned-by-losing-my-global-var/</guid>
		<description><![CDATA[I just got owned by losing my global varible scope when working with include files in php. Had to take a chunk of code out of includes, and put it into a higher level file to get the scope back. I need to learn a work around for this because i hate dealing with messy [...]]]></description>
			<content:encoded><![CDATA[<p>I just got owned by losing my global varible scope when working with include files in php.  Had to take a chunk of code out of includes, and put it into a higher level file to get the scope back.  I need to learn a work around for this because i hate dealing with messy code.</p>]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/status/i-just-got-owned-by-losing-my-global-var/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>D.R.Y. out those useful PHP scripts</title>
		<link>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/</link>
		<comments>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/#comments</comments>
		<pubDate>Tue, 11 May 2010 13:33:39 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[include()]]></category>
		<category><![CDATA[open_dir()]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scandir()]]></category>

		<guid isPermaLink="false">http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/</guid>
		<description><![CDATA[D.R.Y. &#8211; &#8216;Don&#8217;t repeat yourself&#8217; I have a few PHP scripts that come in handy on a lot of different sites. The issue I ran into was that if i needed to make an update to one of these useful scripts, I&#8217;d have to go find all instances of that script, and update them across [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/020161622X/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&amp;pf_rd_s=lpo-top-stripe-1&amp;pf_rd_t=201&amp;pf_rd_i=0974514012&amp;pf_rd_m=ATVPDKIKX0DER&amp;pf_rd_r=0ZHMBPHWDTM42C4BEBAN">D.R.Y. &#8211; &#8216;Don&#8217;t repeat yourself&#8217; </a></p>
<p>I have a few PHP scripts that come in handy on a lot of different sites.  The issue I ran into was that if i needed to make an update to one of these useful scripts, I&#8217;d have to go find all instances of that script, and update them across many domains.</p>
<p>There&#8217;s ways of doing this with ninja SED/grep styles.  But a better way may to be make a folder just below the domains directory, and include files from that directory as needed.</p>
<p>In the example below im stepping backwards from the public html directory into my scripts directory.</p>
<pre><code>include('../../../phpIncludes/test.php');</code></pre>
<p>Thats about the extent of it, and im sure this can be cleaned up a bit.  I was using the scandir() function to find my way to the proper path by echoing out the files of the current directory.</p>
<p>I was also reading open_dir() can cause issues with this technique, and if open_dir() is active it can php scripts from editing lower than the domains&#8217;s root.  open_dir() is a good safety net, but is also prevents some tricks and techniques that just need to happen. A good example is in WordPress sites (as of 2.9) the Media library will throw errors with open_dir() enabled.</p>]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>old jQuery API scraper script</title>
		<link>http://nhaskins.com/post/old-jquery-api-scraper-script/</link>
		<comments>http://nhaskins.com/post/old-jquery-api-scraper-script/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:39:27 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://nhaskins.com/post/old-jquery-api-scraper-script/</guid>
		<description><![CDATA[used this on the jQuery iPhone app to get the data. (.*?) @s', $page, $cmdBlock); //grabs command block //generates a filtered page content for ($i=0; $i&#38;lt;=sizeof($cmdBlock[0]); $i++) { $content .= $cmdBlock[2][$i]; }//end for //plist friendly filters $content = preg_replace('@ @',' ',$content); $content = preg_replace('@&#38;amp;lt\;@','&#38;amp;lt;', $content); // converts less than to a browser viewable text version $content [...]]]></description>
			<content:encoded><![CDATA[<p>used this on the jQuery iPhone app to get the data.</p>
<pre><code>(.*?)

@s', $page, $cmdBlock); //grabs command block
//generates a filtered page content
for ($i=0; $i&amp;lt;=sizeof($cmdBlock[0]); $i++) {
	$content .= $cmdBlock[2][$i];
}//end for
//plist friendly filters
$content = preg_replace('@ @',' ',$content);
$content = preg_replace('@&amp;amp;lt\;@','&amp;amp;lt;', $content); // converts less than to a browser viewable text version
$content = preg_replace('@&amp;amp;gt\;@','&amp;amp;gt;', $content); // converts greater than to a browser viewable text version
$content = preg_replace('@"@','"',$content);       // converts chars to quote
$content = preg_replace('@@','',$content);  

preg_match_all('@<a class="name">(.*?)</a>@s',  $content, $cmdNames); //filters the command names
preg_match_all('@
&lt;div class="desc"&gt;(.*?)&lt;/div&gt;
@s', $content, $cmdDesc);  //filters the command names

for ($i=0; $i&amp;lt;=sizeof($cmdBlock[0])-1; $i++) {

	$final .=  "";
	$final .=  $cmdNames[1][$i];  //need to strip tags 

	$final .=  "\n";
	$final .=  "";
	$final .=  "&amp;lt;h1&amp;gt;".$cmdNames[1][$i]."&amp;lt;/h1&amp;gt;"."&amp;lt;br&amp;gt;";
	$final .=  "&amp;lt;p&amp;gt;".$cmdDesc[1][$i]."&amp;lt;/p&amp;gt;"."&amp;lt;br/&amp;gt;\n";
		if (preg_match('@&lt;code class="javascript"&gt;(.*?)</code>@s', $cmdBlock[0][$i], $cmdEx)) {
			$cmdEx = preg_replace('@&amp;gt\;@','&amp;gt;', $cmdEx); //makes the &gt; text elements
			$cmdEx = preg_replace('@&amp;lt\;@','&amp;lt;', $cmdEx); //makes the &lt; text elements

//syntax highlighting start

            $cmdEx = preg_replace('@\$@',  '&lt;span class="shDollar"&gt;\$&lt;/span&gt;', $cmdEx);
            $cmdEx = preg_replace('@\(@',  '&lt;span class="shQuote"&gt;(&lt;/span&gt;'  , $cmdEx);
            $cmdEx = preg_replace('@\)@',  '&lt;span class="shQuote"&gt;)&lt;/span&gt;'  , $cmdEx);
            $cmdEx = preg_replace('@}@' ,  '&lt;span class="shCurl"&gt;}&lt;/span&gt;'   , $cmdEx);
			$cmdEx = preg_replace('@{@' ,  '&lt;span class="shCurl"&gt;{&lt;/span&gt;'   , $cmdEx);

//syntax highlighting end
	$final .=  "&lt;div id="codeBlock"&gt;".$cmdEx[1]."&lt;/div&gt;"."\n"; } else {$final .=  "\n";
	}//end if
	$final .=  "\n";

}// end for
print &lt;&lt;&lt;_HTML_

\n
_HTML_;
echo $final;
print &lt;&lt;&lt;_HTML_

_HTML_;
?&gt;
</code></pre>
<p>Well that broke the code block&#8230; lol  Im not too surprised.  Note to self, get file attachments setup for easy archiving.</p>
<p>Zip file here: <a href="http://nhaskins.com/wp-content/uploads/2010/05/regex-jquery-api.zip">regex-jquery-api.zip</a></p>]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/post/old-jquery-api-scraper-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

