<?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>MaggsWeb:7 &#187; function</title>
	<atom:link href="http://www.maggsweb.com/tag/function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maggsweb.com</link>
	<description>www.maggsweb.com</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP date dashes to slashes</title>
		<link>http://www.maggsweb.com/php/php-date-dashes-to-slashes/</link>
		<comments>http://www.maggsweb.com/php/php-date-dashes-to-slashes/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 09:19:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1346</guid>
		<description><![CDATA[Converting a date format, simply and quickly. ?View Code PHP&#60;?php &#160; function reverseDate&#40;$dateIn&#41;&#123; list&#40;$year,$month,$day&#41; = explode&#40;'-',$dateIn&#41;; return &#34;$month/$day/$year&#34;; &#125; &#160; ?&#62; This function is used on my own site : http://www.maggsweb.co.uk]]></description>
			<content:encoded><![CDATA[<p>Converting a date format, simply and quickly.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1346code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13462"><td class="code" id="p1346code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">function</span> reverseDate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dateIn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <a href="http://www.php.net/list" onclick="pageTracker._trackPageview('/outgoing/www.php.net/list?referer=');"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$year</span><span style="color: #339933;">,</span><span style="color: #000088;">$month</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/explode?referer=');"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span><span style="color: #000088;">$dateIn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$month</span>/<span style="color: #006699; font-weight: bold;">$day</span>/<span style="color: #006699; font-weight: bold;">$year</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This function is used on my own site : <a href="http://www.maggsweb.co.uk" title="MaggsWeb" onclick="pageTracker._trackPageview('/outgoing/www.maggsweb.co.uk?referer=');">http://www.maggsweb.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/php-date-dashes-to-slashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>display filesize</title>
		<link>http://www.maggsweb.com/php/display-filesize/</link>
		<comments>http://www.maggsweb.com/php/display-filesize/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 10:03:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[filesize]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1266</guid>
		<description><![CDATA[Nicely displaying the filesize, using bytes, megabytes, etc.. ?View Code PHP&#60;?php &#160; function dispFileSize&#40;$file&#41;&#123; $type = array&#40;&#34;b&#34;, &#34;KB&#34;, &#34;MB&#34;, &#34;GB&#34;, &#34;TB&#34;, &#34;PB&#34;&#41;; $pos = 0; $size = filesize&#40;$file&#41;; while &#40;$size &#62;= 1024&#41; &#123; $size /= 1024; $pos++; &#125; return round&#40;$size,1&#41;.&#34; &#34;.$type&#91;$pos&#93;; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Nicely displaying the filesize, using bytes, megabytes, etc..</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1266code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12664"><td class="code" id="p1266code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> dispFileSize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;KB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;MB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;GB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;TB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;PB&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/filesize" onclick="pageTracker._trackPageview('/outgoing/www.php.net/filesize?referer=');"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
     <span style="color: #000088;">$size</span> <span style="color: #339933;">/=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span> 
     <span style="color: #000088;">$pos</span><span style="color: #339933;">++;</span> 
   <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <a href="http://www.php.net/round" onclick="pageTracker._trackPageview('/outgoing/www.php.net/round?referer=');"><span style="color: #990000;">round</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$pos</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/display-filesize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>resubmit sitemap automatically using curl</title>
		<link>http://www.maggsweb.com/php/resubmit-sitemap-automatically-using-curl/</link>
		<comments>http://www.maggsweb.com/php/resubmit-sitemap-automatically-using-curl/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 09:52:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1254</guid>
		<description><![CDATA[How to resubmit generated sitemaps automatically (using cron) or on an event (like re-generation of the sitemap). ?View Code PHP&#60;?php pingSE&#40;urlencode&#40;$url&#41;,'google'&#41;; pingSE&#40;urlencode&#40;$url&#41;,'bing'&#41;; pingSE&#40;urlencode&#40;$url&#41;,'ask'&#41;; ?&#62; And the function goodiness&#8230;. ?View Code PHP&#60;?php &#160; function pingSE&#40;$sitemap,$service&#41;&#123; &#160; switch &#40;$service&#41; &#123; case 'bing': $ping = &#34;http://www.bing.com/webmaster/ping.aspx?siteMap=$sitemap&#34;; break; case 'ask': $ping = &#34;http://submissions.ask.com/ping?sitemap=$sitemap&#34;; break; case 'google': $ping = &#34;http://www.google.com/webmasters/tools/ping?sitemap=$sitemap&#34;; [...]]]></description>
			<content:encoded><![CDATA[<p>How to resubmit generated sitemaps automatically (using cron) or on an event (like re-generation of the sitemap).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1254code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12547"><td class="code" id="p1254code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
pingSE<span style="color: #009900;">&#40;</span><a href="http://www.php.net/urlencode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/urlencode?referer=');"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'google'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pingSE<span style="color: #009900;">&#40;</span><a href="http://www.php.net/urlencode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/urlencode?referer=');"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'bing'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pingSE<span style="color: #009900;">&#40;</span><a href="http://www.php.net/urlencode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/urlencode?referer=');"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'ask'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>And the function goodiness&#8230;.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1254code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12548"><td class="code" id="p1254code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> pingSE<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sitemap</span><span style="color: #339933;">,</span><span style="color: #000088;">$service</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$service</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'bing'</span><span style="color: #339933;">:</span>
      <span style="color: #000088;">$ping</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.bing.com/webmaster/ping.aspx?siteMap=<span style="color: #006699; font-weight: bold;">$sitemap</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ask'</span><span style="color: #339933;">:</span>
      <span style="color: #000088;">$ping</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://submissions.ask.com/ping?sitemap=<span style="color: #006699; font-weight: bold;">$sitemap</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'google'</span><span style="color: #339933;">:</span>
      <span style="color: #000088;">$ping</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.google.com/webmasters/tools/ping?sitemap=<span style="color: #006699; font-weight: bold;">$sitemap</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$curl_handle</span><span style="color: #339933;">=</span><a href="http://www.php.net/curl_init" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_init?referer=');"><span style="color: #990000;">curl_init</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_setopt?referer=');"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_URL<span style="color: #339933;">,</span><span style="color: #000088;">$ping</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_setopt?referer=');"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_setopt?referer=');"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$run</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_exec" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_exec?referer=');"><span style="color: #990000;">curl_exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_getinfo" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_getinfo?referer=');"><span style="color: #990000;">curl_getinfo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_close" onclick="pageTracker._trackPageview('/outgoing/www.php.net/curl_close?referer=');"><span style="color: #990000;">curl_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http_code'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>       
       <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Sitemap successfully submitted&quot;</span><span style="color: #339933;">;</span>       
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/resubmit-sitemap-automatically-using-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date format switching for MySQL</title>
		<link>http://www.maggsweb.com/php/date-format-switch-mysql/</link>
		<comments>http://www.maggsweb.com/php/date-format-switch-mysql/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 09:48:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1249</guid>
		<description><![CDATA[Easy way of switching between mysql and &#8220;normal&#8221; dates (english, not american)&#8230; ?View Code PHP&#60;?php function flipdate&#40;$dt, $seperator_in = '-', $seperator_out = '-'&#41; &#123; return implode&#40;$seperator_out, array_reverse&#40;explode&#40;$seperator_in, $dt&#41;&#41;&#41;; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Easy way of switching between mysql and &#8220;normal&#8221; dates (english, not american)&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1249code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p124910"><td class="code" id="p1249code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> flipdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dt</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seperator_in</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seperator_out</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'-'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <a href="http://www.php.net/implode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/implode?referer=');"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$seperator_out</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_reverse" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array_reverse?referer=');"><span style="color: #990000;">array_reverse</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/explode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/explode?referer=');"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$seperator_in</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/date-format-switch-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show Bytes</title>
		<link>http://www.maggsweb.com/php/show-bytes/</link>
		<comments>http://www.maggsweb.com/php/show-bytes/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 13:13:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=820</guid>
		<description><![CDATA[Haven&#8217;t actually used this one, but it does work&#8230; ?View Code PHP&#60;?php function size_format&#40; $bytes, $decimals = null &#41; &#123; $quant = array&#40; // ========================= Origin ==== 'TB' =&#62; 1099511627776, // pow( 1024, 4) 'GB' =&#62; 1073741824, // pow( 1024, 3) 'MB' =&#62; 1048576, // pow( 1024, 2) 'kB' =&#62; 1024, // pow( 1024, 1) [...]]]></description>
			<content:encoded><![CDATA[<p>Haven&#8217;t actually used this one, but it does work&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p820code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p82012"><td class="code" id="p820code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> size_format<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$bytes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$decimals</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$quant</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
		<span style="color: #666666; font-style: italic;">// ========================= Origin ====</span>
		<span style="color: #0000ff;">'TB'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1099511627776</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// pow( 1024, 4)</span>
		<span style="color: #0000ff;">'GB'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1073741824</span><span style="color: #339933;">,</span>     <span style="color: #666666; font-style: italic;">// pow( 1024, 3)</span>
		<span style="color: #0000ff;">'MB'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1048576</span><span style="color: #339933;">,</span>        <span style="color: #666666; font-style: italic;">// pow( 1024, 2)</span>
		<span style="color: #0000ff;">'kB'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">,</span>           <span style="color: #666666; font-style: italic;">// pow( 1024, 1)</span>
		<span style="color: #0000ff;">'B '</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>              <span style="color: #666666; font-style: italic;">// pow( 1024, 0)</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$quant</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$unit</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mag</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/doubleval" onclick="pageTracker._trackPageview('/outgoing/www.php.net/doubleval?referer=');"><span style="color: #990000;">doubleval</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bytes</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$mag</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$bytes</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$mag</span><span style="color: #339933;">,</span> <span style="color: #000088;">$decimals</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$unit</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/show-bytes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump variables</title>
		<link>http://www.maggsweb.com/php/dumpr-variables/</link>
		<comments>http://www.maggsweb.com/php/dumpr-variables/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 13:09:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=926</guid>
		<description><![CDATA[This is my extension of an existing function, adatped for my requirements. ?View Code PHP&#60;?php function dumpr&#40;$VARIABLE_NAME, $DATA&#41;&#123; if &#40;is_object&#40;$DATA&#41;&#41; &#123; $data = &#40;array&#41; $DATA; &#125; elseif &#40;is_array&#40;$DATA&#41;&#41; &#123; $data = $DATA; &#125; else &#123; $data = strval&#40;$DATA&#41;; &#125; $output = &#34;&#60;table class='dumpr'&#62;&#34;; $output .= &#34;&#60;head&#62;&#34;; $output .= &#34;&#60;tr&#62;&#34;; $output .= &#34;&#60;th colspan='2'&#62;&#34; . $VARIABLE_NAME [...]]]></description>
			<content:encoded><![CDATA[<p>This is my extension of an existing function, adatped for my requirements.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p926code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p92614"><td class="code" id="p926code14"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> dumpr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$VARIABLE_NAME</span><span style="color: #339933;">,</span> <span style="color: #000088;">$DATA</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_object" onclick="pageTracker._trackPageview('/outgoing/www.php.net/is_object?referer=');"><span style="color: #990000;">is_object</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$DATA</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$DATA</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/is_array?referer=');"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$DATA</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$DATA</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strval" onclick="pageTracker._trackPageview('/outgoing/www.php.net/strval?referer=');"><span style="color: #990000;">strval</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$DATA</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;table class='dumpr'&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;head&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;th colspan='2'&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$VARIABLE_NAME</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/th&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/head&gt;&lt;body&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/is_array?referer=');"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//$value = dumpr($key, $value);</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$key</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$value</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td colspan=2&gt;<span style="color: #006699; font-weight: bold;">$data</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/body&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Use like this:<br />
echo dumpr(&#8216;NAME&#8217;,$var);<br />
echo dumpr(&#8216;SESSION&#8217;,$_SESSION);<br />
etc..</p>
<p>Displays a nicely formatted table, with values of a string / array / object clearly displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/dumpr-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strip non-alphanumeric characters</title>
		<link>http://www.maggsweb.com/php/strip-non-alphanumeric-characters/</link>
		<comments>http://www.maggsweb.com/php/strip-non-alphanumeric-characters/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 13:04:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=928</guid>
		<description><![CDATA[Remove all non alpha-numeric characters from a string. ?View Code PHP&#60;?php function alphanumericAndSpace&#40; $string &#41; &#123; return preg_replace&#40;'/[^a-zA-Z0-9\s]/', '', $string&#41;; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Remove all non alpha-numeric characters from a string.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p928code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p92816"><td class="code" id="p928code16"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000000; font-weight: bold;">function</span> alphanumericAndSpace<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$string</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[^a-zA-Z0-9\s]/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/strip-non-alphanumeric-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Tiny URL</title>
		<link>http://www.maggsweb.com/php/automated-tiny-url/</link>
		<comments>http://www.maggsweb.com/php/automated-tiny-url/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 07:31:42 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1066</guid>
		<description><![CDATA[Function to create TinyURL&#8217;s on-the-fly http://tinyurl.com/ ?View Code PHP&#160; &#60;?php function getTinyUrl&#40;$url&#41; &#123; $tinyurl = file_get_contents&#40;&#34;http://tinyurl.com/api-create.php?url=&#34;.$url&#41;; return $tinyurl; &#125; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Function to create TinyURL&#8217;s on-the-fly<br />
<a href="http://tinyurl.com/" onclick="pageTracker._trackPageview('/outgoing/tinyurl.com/?referer=');">http://tinyurl.com/</a></p>
<p><span id="more-1066"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1066code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p106618"><td class="code" id="p1066code18"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> getTinyUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
     <span style="color: #000088;">$tinyurl</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://tinyurl.com/api-create.php?url=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
     <span style="color: #b1b100;">return</span> <span style="color: #000088;">$tinyurl</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/automated-tiny-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compressing CSS files &#8211; on the fly</title>
		<link>http://www.maggsweb.com/php/compressing-files-on-the-fly/</link>
		<comments>http://www.maggsweb.com/php/compressing-files-on-the-fly/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 07:30:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=978</guid>
		<description><![CDATA[I hate compressing CSS files as they become totally unreadable for editing. I end up keeping 2 versions, compressed and uncompressed, etc.. But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;. Now that has solved the problem. ?View Code PHP&#60;?php &#160; header&#40;'Content-type: text/css'&#41;; &#160; ob_start&#40;&#34;compress&#34;&#41;; &#160; function compress&#40;$buffer&#41; &#123; /* remove comments [...]]]></description>
			<content:encoded><![CDATA[<p>I hate compressing CSS files as they become totally unreadable for editing.  I end up keeping 2 versions, compressed and uncompressed, etc..   But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;.  Now that has solved the problem.</p>
<p><span id="more-978"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p97821"><td class="code" id="p978code21"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<a href="http://www.php.net/header" onclick="pageTracker._trackPageview('/outgoing/www.php.net/header?referer=');"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: text/css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_start" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_start?referer=');"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;compress&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress<span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/* remove comments */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!/\*[^*]*\*+([^/][^*]*\*+)*/!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">/* remove tabs, spaces, newlines, etc. */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* your css files */</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'master.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'typography.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'grid.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'print.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'handheld.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_end_flush" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_end_flush?referer=');"><span style="color: #990000;">ob_end_flush</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Use it like this :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code22'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p97822"><td class="code" id="p978code22"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;style.php&quot; type=&quot;text/css&quot; media=&quot;all&quot;&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/compressing-files-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First date of the week</title>
		<link>http://www.maggsweb.com/php/first-date-of-the-week/</link>
		<comments>http://www.maggsweb.com/php/first-date-of-the-week/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:06:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=965</guid>
		<description><![CDATA[Just a little script I wrote to work out the date of the first day of the week. ?View Code PHP&#60;?php &#160; $yearNow = date&#40;'Y', $time&#41;; $monthNow = date&#40;'m', $time&#41;; $dayNow = date&#40;'d', $time&#41;; &#160; $first_day_of_week = 'Mon'; // Sat &#124; Sun &#124; Mon &#124; etc.. $day = $dayNow; // dont overwrite $dayNow! &#160; while [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little script I wrote to work out the date of the first day of the week.<br />
<span id="more-965"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p965code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p96524"><td class="code" id="p965code24"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$yearNow</span>  <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$monthNow</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dayNow</span>   <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$first_day_of_week</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mon'</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Sat | Sun | Mon | etc..  </span>
<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dayNow</span><span style="color: #339933;">;</span>               <span style="color: #666666; font-style: italic;">// dont overwrite $dayNow!</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$weekday</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$first_date_of_week</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span> 
     <span style="color: #000088;">$day</span><span style="color: #339933;">--;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h2&gt;First date of week is &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/h2&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/first-date-of-the-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

