<?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>Fahd Murtaza&#187; PHP</title>
	<atom:link href="http://www.fahdmurtaza.com/myblog/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fahdmurtaza.com/myblog</link>
	<description>Portfolio &#38; Blog</description>
	<lastBuildDate>Sat, 04 Feb 2012 06:47:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>PHP: Removing last instance of a character within text using Regex</title>
		<link>http://www.fahdmurtaza.com/myblog/2011/08/28/php-removing-last-instance-of-a-character-within-text-using-regex.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2011/08/28/php-removing-last-instance-of-a-character-within-text-using-regex.html#comments</comments>
		<pubDate>Sun, 28 Aug 2011 07:54:48 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[remove]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=918</guid>
		<description><![CDATA[I recently encountered a situation where I needed to remove the last instance of the character &#8216;&#124;&#8217; in the menu that was being dynamically generated. So I came up with the following code &#60;? $menu = &#039;I AM &#124;NOT&#124; A BAD &#124;BOY&#124;&#039;; $menu = preg_replace(&#039;/[&#124;]([^&#124;]*$)/&#039;, &#039;$2&#039;, $menu); echo $menu.&#34;\n&#34;; ?&#62; The output would be I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2011%2F08%2F28%2Fphp-removing-last-instance-of-a-character-within-text-using-regex.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2011%2F08%2F28%2Fphp-removing-last-instance-of-a-character-within-text-using-regex.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=character,PHP,preg_replace,regex,remove&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I recently encountered a situation where I needed to remove the last instance of the character &#8216;|&#8217; in the menu that was being dynamically generated. So I came up with the following code</p>
<pre class="brush: php">&lt;?
$menu = &#039;I AM |NOT| A BAD |BOY|&#039;;
$menu = preg_replace(&#039;/[|]([^|]*$)/&#039;, &#039;$2&#039;, $menu);
echo $menu.&quot;\n&quot;;
?&gt;</pre>
<p>The output would be </p>
<pre class="brush: php">I AM |NOT| A BAD |BOY</pre>
<p>And that removes the last instance of a character (in this case a pipe sign, i.e &#8216;|&#8217; ). Hope that helps others.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2011%2F08%2F28%2Fphp-removing-last-instance-of-a-character-within-text-using-regex.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2011/08/28/php-removing-last-instance-of-a-character-within-text-using-regex.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP: Text cropping with defining the number of characters, words or sentences</title>
		<link>http://www.fahdmurtaza.com/myblog/2009/03/18/585.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2009/03/18/585.html#comments</comments>
		<pubDate>Wed, 18 Mar 2009 09:53:50 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Tips]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[characters]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[crop by number of]]></category>
		<category><![CDATA[crop text]]></category>
		<category><![CDATA[sentences]]></category>
		<category><![CDATA[string manipulation]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=585</guid>
		<description><![CDATA[I was asked to develop the functionality in a such a way that text can be cropped in these three ways.

   1. With defining the number of words.
   2. With defining the numbers of characters.
   3. With defining the number of sentences.

Here is a set of functions that helps you crop a text in three different ways. The usage of the function is also mentioned at the end f the script.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2F585.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2F585.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=characters,crop,crop+by+number+of,crop+text,PHP,sentences,string+manipulation,strings,words&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I have recently been working on PHP RSS reader script that was supposed to do three different things with RSS description text. To make a teaser RSS text, I was asked to develop the functionality in a such a way that text can be cropped in these three ways.</p>
<ul>
<li><strong>with defining the number of words.</strong></li>
<li><strong>with defining the numbers of characters.</strong></li>
<li><strong>with defining the number of sentences.</strong></li>
</ul>
<p>Here is a set of  functions that helps you crop a text in three different ways. The usage of the function is also mentioned at the end f the script.<span id="more-585"></span><br />
<code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php</span></span></code></p>
<p><span style="color: #ff8000;">/**<br />
* cropsentence()<br />
*<br />
* @param mixed $str<br />
* @param mixed $noof<br />
* @param integer $mode<br />
// 0 means crop by no of characters // 1 means crop by no of sentences // 2 means crop by number of words<br />
* @param string $appendwith<br />
* @return<br />
*/<br />
</span><span style="color: #007700;">function </span><span style="color: #0000bb;">cropsentence</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$noof</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$mode </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$appendwith </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;&#8230;&#8221;</span><span style="color: #007700;">)<br />
{<br />
if (</span><span style="color: #0000bb;">strlen</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">) &gt; </span><span style="color: #0000bb;">$chars</span><span style="color: #007700;">) {<br />
if (</span><span style="color: #0000bb;">$mode </span><span style="color: #007700;">== </span><span style="color: #0000bb;">0</span><span style="color: #007700;">) { </span><span style="color: #ff8000;">// 0 means crop by no of characters<br />
</span><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #0000bb;">substr</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">0</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$noof</span><span style="color: #007700;">);<br />
} elseif (</span><span style="color: #0000bb;">$mode </span><span style="color: #007700;">== </span><span style="color: #0000bb;">1</span><span style="color: #007700;">) { </span><span style="color: #ff8000;">// 1 means crop by no of sentences<br />
</span><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #0000bb;">getLeadingSentences</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$noof</span><span style="color: #007700;">);<br />
} elseif (</span><span style="color: #0000bb;">$mode </span><span style="color: #007700;">== </span><span style="color: #0000bb;">2</span><span style="color: #007700;">) { </span><span style="color: #ff8000;">// 2 means crop by number of words<br />
</span><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #0000bb;">wordTrim</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$noof</span><span style="color: #007700;">);</span></p>
<p>} elseif (<span style="color: #0000bb;">$mode </span><span style="color: #007700;">&lt; </span><span style="color: #0000bb;">0 </span><span style="color: #007700;">|| </span><span style="color: #0000bb;">$mode </span><span style="color: #007700;">&gt; </span><span style="color: #0000bb;">2</span><span style="color: #007700;">) { </span><span style="color: #ff8000;">// others means do nothing<br />
</span><span style="color: #007700;">echo </span><span style="color: #dd0000;">&#8220;The current mode is not correct.&#8221;</span><span style="color: #007700;">;<br />
}<br />
</span><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #0000bb;">$str </span><span style="color: #007700;">. </span><span style="color: #0000bb;">$appendwith</span><span style="color: #007700;">;<br />
return </span><span style="color: #0000bb;">$str</span><span style="color: #007700;">;<br />
} else {<br />
return </span><span style="color: #0000bb;">$str</span><span style="color: #007700;">;<br />
}<br />
}</span></p>
<p><span style="color: #ff8000;">//getLeadingSentences<br />
//Copyright (c) 2000 Jason R. Pitoniak.  All rights reserved.<br />
//jason@interbrite.com http://www.interbrite.com</span></p>
<p>//If you find this code useful, find a bug, or have a suggestion,<br />
//please email me.  Feel free to use this code for any purpose.</p>
<p>/**<br />
* getLeadingSentences()<br />
*<br />
* @param mixed $data<br />
* @param mixed $max<br />
* @return<br />
*/<br />
<span style="color: #007700;">function </span><span style="color: #0000bb;">getLeadingSentences</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$data</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">)<br />
{<br />
</span><span style="color: #ff8000;">//given string $data, will return the first $max sentences in that string</span></p>
<p>//in: $data = the string to parse, $max = maximum # of sentences to return<br />
//returns: string containing the first $max sentences<br />
//(If the # of sentences in the string is less than $max,<br />
//then entire string will be returned.)</p>
<p>//a sentence is any charactors except ., !, and ?<br />
//any number of times,  plus one or more .s, ?s, or !s<br />
//and any leading or trailing whitespace:<br />
<span style="color: #0000bb;">$re </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;^s*[^.?!]+[.?!]+s*&#8221;</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$out </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;&#8221;</span><span style="color: #007700;">;<br />
for (</span><span style="color: #0000bb;">$i </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i </span><span style="color: #007700;">&lt; </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i</span><span style="color: #007700;">++) {<br />
if (</span><span style="color: #0000bb;">ereg</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$re</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$data</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$match</span><span style="color: #007700;">)) {<br />
</span><span style="color: #ff8000;">//if a sentence is found, take it out of $data and add it to $out<br />
</span><span style="color: #0000bb;">$out </span><span style="color: #007700;">.= </span><span style="color: #0000bb;">$match</span><span style="color: #007700;">[</span><span style="color: #0000bb;">0</span><span style="color: #007700;">];<br />
</span><span style="color: #0000bb;">$data </span><span style="color: #007700;">= </span><span style="color: #0000bb;">ereg_replace</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$re</span><span style="color: #007700;">, </span><span style="color: #dd0000;">&#8220;&#8221;</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$data</span><span style="color: #007700;">);<br />
} else {<br />
</span><span style="color: #0000bb;">$i </span><span style="color: #007700;">= </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">;<br />
}<br />
}<br />
return </span><span style="color: #0000bb;">$out</span><span style="color: #007700;">;<br />
}</span></p>
<p><span style="color: #ff8000;">/**<br />
* getLeadingWords()<br />
*<br />
* @param mixed $data<br />
* @param mixed $max<br />
* @return<br />
*/<br />
</span><span style="color: #007700;">function </span><span style="color: #0000bb;">getLeadingWords</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$data</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">)<br />
{<br />
</span><span style="color: #ff8000;">//given string $data, will return the first $max sentences in that string</span></p>
<p>//in: $data = the string to parse, $max = maximum # of sentences to return<br />
//returns: string containing the first $max sentences<br />
//(If the # of sentences in the string is less than $max,<br />
//then entire string will be returned.)</p>
<p>//a sentence is any charactors except ., !, and ?<br />
//any number of times,  plus one or more .s, ?s, or !s<br />
//and any leading or trailing whitespace:<br />
<span style="color: #0000bb;">$re </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;^s*[^.?!]+[.?!]+s*&#8221;</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$out </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;&#8221;</span><span style="color: #007700;">;<br />
for (</span><span style="color: #0000bb;">$i </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i </span><span style="color: #007700;">&lt; </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i</span><span style="color: #007700;">++) {<br />
if (</span><span style="color: #0000bb;">ereg</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$re</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$data</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$match</span><span style="color: #007700;">)) {<br />
</span><span style="color: #ff8000;">//if a sentence is found, take it out of $data and add it to $out<br />
</span><span style="color: #0000bb;">$out </span><span style="color: #007700;">.= </span><span style="color: #0000bb;">$match</span><span style="color: #007700;">[</span><span style="color: #0000bb;">0</span><span style="color: #007700;">];<br />
</span><span style="color: #0000bb;">$data </span><span style="color: #007700;">= </span><span style="color: #0000bb;">ereg_replace</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$re</span><span style="color: #007700;">, </span><span style="color: #dd0000;">&#8220;&#8221;</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$data</span><span style="color: #007700;">);<br />
} else {<br />
</span><span style="color: #0000bb;">$i </span><span style="color: #007700;">= </span><span style="color: #0000bb;">$max</span><span style="color: #007700;">;<br />
}<br />
}<br />
return </span><span style="color: #0000bb;">$out</span><span style="color: #007700;">;<br />
}</span></p>
<p><span style="color: #ff8000;">/**<br />
* wordTrim()<br />
*<br />
* @param mixed $str<br />
* @param mixed $len<br />
* @return<br />
*/<br />
</span><span style="color: #007700;">function </span><span style="color: #0000bb;">wordTrim</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$len</span><span style="color: #007700;">)<br />
{<br />
</span><span style="color: #0000bb;">$wordCount </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$charCount </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">;</span></p>
<p><span style="color: #0000bb;">$length </span><span style="color: #007700;">= </span><span style="color: #0000bb;">strlen</span><span style="color: #007700;">(</span><span style="color: #0000bb;">strip_tags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">));<br />
for (</span><span style="color: #0000bb;">$i </span><span style="color: #007700;">= </span><span style="color: #0000bb;">0</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i </span><span style="color: #007700;">&lt; </span><span style="color: #0000bb;">$length</span><span style="color: #007700;">; </span><span style="color: #0000bb;">$i</span><span style="color: #007700;">++) {<br />
if (</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">[</span><span style="color: #0000bb;">$i</span><span style="color: #007700;">] == </span><span style="color: #dd0000;">&#8216; &#8217;</span><span style="color: #007700;">) {<br />
</span><span style="color: #0000bb;">$wordCount</span><span style="color: #007700;">++;<br />
</span><span style="color: #0000bb;">$charCount</span><span style="color: #007700;">++;<br />
if (</span><span style="color: #0000bb;">$wordCount </span><span style="color: #007700;">== </span><span style="color: #0000bb;">$len</span><span style="color: #007700;">)<br />
break;<br />
} else {<br />
</span><span style="color: #0000bb;">$charCount</span><span style="color: #007700;">++;<br />
} </span><span style="color: #ff8000;"># end if<br />
</span><span style="color: #007700;">} </span><span style="color: #ff8000;"># end for loop</span></p>
<p><span style="color: #0000bb;">$newstr </span><span style="color: #007700;">= </span><span style="color: #0000bb;">substr</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">0</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$charCount</span><span style="color: #007700;">);<br />
return </span><span style="color: #0000bb;">$newstr</span><span style="color: #007700;">;<br />
} </span><span style="color: #ff8000;"># end function</span></p>
<p># Example used for testing purpose</p>
<p><span style="color: #0000bb;">$str2 </span><span style="color: #007700;">= </span><span style="color: #dd0000;">&#8220;Hello there I work for you. I have been working for other guys, but you are the coolest guy among them.<br />
Also I really like the way you guide me with new technologies and the latest trends. You always tell me to keep working hard!&#8221;</span><span style="color: #007700;">;<br />
echo </span><span style="color: #0000bb;">cropsentence</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str2</span><span style="color: #007700;">, </span><span style="color: #0000bb;">22</span><span style="color: #007700;">, </span><span style="color: #0000bb;">2</span><span style="color: #007700;">);</span></p>
<p><span style="color: #0000bb;">?&gt;</span></p>
<h3>Usage</h3>
<p><span style="color: #0000bb;">cropsentence</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$noof</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$mode</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$appendwith </span><span style="color: #007700;">);</span></p>
<p><strong>$str:</strong> This is the string / text to be cropped</p>
<p><strong>$noof: </strong>Number of characters/words/sentences based on the $mode parameter</p>
<p><strong>$mode: </strong>Three values of $mode can be defined</p>
<p>1. <strong>0</strong> means crop by no of characters.<br />
2. <strong>1 </strong>means crop by no of sentences .<br />
3.<strong> 2</strong> means crop by number of words.</p>
<p><strong>$appendwith: </strong>This can be any characters like &#8216;&#8230;&#8217; , &#8216;&#8230;more&#8217; etc which will be appended with the cropped text when its returned.</p>
<p><strong>Download:</strong></p>
<p>You can download the script here.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2F585.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2009/03/18/585.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to make sure your PHP RSS feed reader doesn&#8217;t mess up</title>
		<link>http://www.fahdmurtaza.com/myblog/2009/03/18/how-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2009/03/18/how-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html#comments</comments>
		<pubDate>Wed, 18 Mar 2009 07:20:00 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Tips]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[crop html]]></category>
		<category><![CDATA[crop text]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[reader]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[strip_tags]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=579</guid>
		<description><![CDATA[This post helps you with cropping long text into small with taking care of html tags that can get cropped in the mid due to unknown length of cropping.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2Fhow-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2Fhow-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=crop+html,crop+text,html,PHP,reader,RSS,strip_tags&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I was recently working on a custom RSS feed reader where the prior most concern of the client was being able to crop the text with respect to the</p>
<ol>
<li>Number of words.</li>
<li>Numbers of characters.</li>
<li>Number of sentences.<span id="more-579"></span></li>
</ol>
<p>So a very important measure had to be taken. Since the cropping can end up giving us a broken link if its text  is cropped before the &lt;/a&gt; tag, our output can end up as a disaster.</p>
<p>So here is a little script that can help you strip off your html tags in such situations.<br />
<code><br />
&lt;?php</code></p>
<p><code>$text = "This is a link to &lt;a href='http://www.fahdmurtaza.com/myblog/'&gt;Fahd Murtaza's &lt;/a&gt; site!";<br />
echo strip_tags($text, "<a>");</a></code></p>
<p><code><a>?&gt;</a></code></p>
<p>So <strong>strip_tags</strong> would end up removing anything from the <strong>$text</strong>. The second parameter of the <strong>strip_tags</strong> will simply declare any html tags you want to neglect while stripping the text. Off course you will need to deal with them separately in text cropping situations like I had.</p>
<p>Here is one more example.</p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
$text </span><span style="color: #007700;">= </span><span style="color: #dd0000;">'&lt;p&gt;Test paragraph.&lt;/p&gt;&lt;!-- Comment --&gt; &lt;a href="#fragment"&gt;Other text&lt;/a&gt;'</span><span style="color: #007700;">;<br />
echo </span><span style="color: #0000bb;">strip_tags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$text</span><span style="color: #007700;">);<br />
echo </span><span style="color: #dd0000;">"\n"</span><span style="color: #007700;">;</p>
<p></span><span style="color: #ff8000;">// Allow &lt;p&gt; and &lt;a&gt;<br />
</span><span style="color: #007700;">echo </span><span style="color: #0000bb;">strip_tags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$text</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'&lt;p&gt;&lt;a&gt;'</span><span style="color: #007700;">);<br />
</span><span style="color: #0000bb;">?&gt;</span></span></code></div>
<div class="phpcode"></div>
<div class="phpcode">For more infomation, please check this function&#8217;s reference on <a title="strip_tags PHP Function" href="http://www.php.net/strip_tags" target="_blank">PHP&#8217;s official website</a>.</div>
<div class="phpcode"></div>
<div class="phpcode">Also if you are interested in getting the PHP RSS reader script I did, I would encourage you to visit this link  of my next post. Also, if you are intersted in having the script that does the cropping by</div>
<div class="phpcode">
<ol>
<li>Number of words.</li>
<li>Numbers of characters.</li>
<li>Number of sentences.</li>
</ol>
<p>you can get it here.</p></div>
<div class="phpcode"></div>
<div class="phpcode"></div>
</div>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F18%2Fhow-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2009/03/18/how-to-make-sure-your-php-rss-feed-reader-doesnt-mess-up.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I am on home page of oDesk, feels great</title>
		<link>http://www.fahdmurtaza.com/myblog/2009/03/17/i-am-on-home-page-of-odesk-feels-great.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2009/03/17/i-am-on-home-page-of-odesk-feels-great.html#comments</comments>
		<pubDate>Tue, 17 Mar 2009 04:33:55 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[expert]]></category>
		<category><![CDATA[fahd]]></category>
		<category><![CDATA[Fahd Murtaza]]></category>
		<category><![CDATA[murtaza]]></category>
		<category><![CDATA[oDesk]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=571</guid>
		<description><![CDATA[Hi guys I am feeling good right now. Have been working on oDesk from Feb 17, 2009. And its good you get paid on hourly basis. I like oDesk the most among freelancing sites I have worked on. Anyhow, I took a few screen shots to show you that I was once featured on home [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F17%2Fi-am-on-home-page-of-odesk-feels-great.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F17%2Fi-am-on-home-page-of-odesk-feels-great.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=expert,fahd,Fahd+Murtaza,murtaza,oDesk,PHP,Portfolio,Wordpress&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hi guys</p>
<p>I am feeling good right now. Have been working on oDesk from Feb 17, 2009. And its good you get paid on hourly basis. I like oDesk the most among freelancing sites I have worked on. Anyhow, I took a few screen shots to show you that I was once featured on home page on oDesk.</p>
<p><a href="http://www.odesk.com/users/~~869cd6b2b81d3b45"><img class="alignnone size-medium wp-image-575" title="Fahd Murtaza featured on home page of odesk" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2009/03/fahd-murtaza-featured-on-home-page-of-odesk-292x300.png" alt="" width="292" height="300" /></a></p>
<p><span id="more-571"></span></p>
<div id="attachment_574" class="wp-caption alignnone" style="width: 310px"><a href="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2009/03/tests.png"><img class="size-medium wp-image-574" title="oDesk Tests passed by Fahd Murtaza" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2009/03/tests-300x131.png" alt="Fahd Murtaza's Passed Expert Rating Tests" width="300" height="131" /></a><p class="wp-caption-text">Fahd Murtaza</p></div>
<div id="attachment_572" class="wp-caption alignnone" style="width: 310px"><a href="http://www.odesk.com/users/~~869cd6b2b81d3b45"><img class="size-medium wp-image-572" title="Profile Overview" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2009/03/profile-overview-300x131.png" alt="My profile overview on oDesk" width="300" height="131" /></a><p class="wp-caption-text">My profile overview on oDesk</p></div>
<div id="attachment_573" class="wp-caption alignnone" style="width: 310px"><a href="http://www.odesk.com/users/~~869cd6b2b81d3b45"><img class="size-medium wp-image-573" title="Resume Profile on oDesk" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2009/03/profile-resume-300x131.png" alt="My Resume Profile on oDesk" width="300" height="131" /></a><p class="wp-caption-text">My Resume Profile on oDesk</p></div>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2009%2F03%2F17%2Fi-am-on-home-page-of-odesk-feels-great.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2009/03/17/i-am-on-home-page-of-odesk-feels-great.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: How to rewmove last comma from a string</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/11/25/php-how-to-rewmove-last-comma-from-a-string.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/11/25/php-how-to-rewmove-last-comma-from-a-string.html#comments</comments>
		<pubDate>Tue, 25 Nov 2008 10:58:34 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[PHP Tips]]></category>
		<category><![CDATA[comma]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[removal]]></category>
		<category><![CDATA[removing]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=556</guid>
		<description><![CDATA[Hello readers A few minutes ago, I had a situation where For example you have a string which is like &#8220;cat,cow,hamster,owl,&#8221; and you want to remove the last comma from the string then you can use this code &#60;?php $string="cat,cow,hamster,owl,"; echo $string."&#60;br/&#62;"; $string= substr($string, 0, strlen($string)-1); echo $string; ?&#62; This comes really handy in many [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F11%2F25%2Fphp-how-to-rewmove-last-comma-from-a-string.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F11%2F25%2Fphp-how-to-rewmove-last-comma-from-a-string.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=comma,PHP,removal,removing,string&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello readers</p>
<p>A few minutes ago, I had a situation where</p>
<p>For example you have a string which is like &#8220;cat,cow,hamster,owl,&#8221;</p>
<p>and you want to remove the last comma from the string</p>
<p>then you can use this code</p>
<p><code>&lt;?php<br />
$string="cat,cow,hamster,owl,";<br />
echo $string."&lt;br/&gt;";<br />
$string= substr($string, 0, strlen($string)-1);<br />
echo $string;<br />
?&gt;</code></p>
<p>This comes really handy in many situations.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F11%2F25%2Fphp-how-to-rewmove-last-comma-from-a-string.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/11/25/php-how-to-rewmove-last-comma-from-a-string.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thanks Rasmus Lerdorf, you made my day</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html#comments</comments>
		<pubDate>Fri, 12 Sep 2008 04:44:52 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[best MVC framework]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Lerdorf]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rasmus]]></category>
		<category><![CDATA[Rasmus Lerdorf]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=499</guid>
		<description><![CDATA[OK folks, I think I had announced on my blog that I am under contract with Packt Publishing to write a book about PHP team oriented development. The official title would be &#8220;PHP Team Development&#8221;. This is not a publicity campaign of my book yet another sigh of relief that what I am doing is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F12%2Fthanks-rasmus-lerdorf-you-made-my-day.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F12%2Fthanks-rasmus-lerdorf-you-made-my-day.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=best+MVC+framework,CodeIgniter,Lerdorf,MVC,PHP,Rasmus,Rasmus+Lerdorf&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>OK folks, I think I had announced on my blog that I am under contract with <a href="http://www.packtpub.com" target="_blank"><strong>Packt Publishing</strong></a> to write a book about PHP team oriented development. The official title would be<strong> &#8220;PHP Team Development&#8221;. </strong></p>
<p>This is not a publicity campaign of my book yet another sigh of relief that what I am doing is even supported by the creator of PHP. Yes his name is <strong>Rasmus Lerdorf</strong>. The guy has been doing quite a research about PHP frameworks. Anyhow, the great news is that he found <a href="http://www.codeigniter.com" target="_blank">CodeIgniter </a>the best optimal framework for PHP MVC based  application development. OK so I am sharing the complete article from sitepoint where I read the news.</p>
<p><span id="more-499"></span></p>
<p class="blogauthor"><span class="regular_author">by <a title="David Peterson's Author Bio" href="http://www.sitepoint.com/articlelist/497">David Peterson</a></span></p>
<p><!-- load needed syntax highlighting brushes --><img src="http://szeged2008.drupalcon.org/files/Rasmus.jpg" alt="" align="right" /> This is the fist time I have heard <a href="http://en.wikipedia.org/wiki/Rasmus_Lerdorf">Rasmus Lerdorf</a> speak and it was entertaining to say the least. Refreshing would another way to describe it, I enjoy hearing real opinions and not holding back — Rasmus doesn’t hold back.</p>
<p>Just a short background, Rasmus Lerdorf is the creator of PHP and still continues as a core developer to the PHP project.</p>
<p><strong>PHP frameworks</strong></p>
<p>In his address he choose to highlight PHP frameworks (Drupal was not spared) and how poor they are at performance. Not only are they slow, but their &#8220;jack-of-all-trades&#8221; attitude leads developers down the wrong path by not using what is best for the job. He continues on by stating that PHP developers really need to think about performance for not only scalability reasons but for green reasons. If programs were more efficient it would cut the number of data centres and would reduce energy needs as a result. In our newly emerging age of energy awareness this does become an important aspect and I am glad that he is raising awareness.</p>
<p>Back to frameworks, he started by discussing a database heavy Twitter mashup that he created. This does a lot of database calls and a lot of behind the scenes work. By hand-tuning it he was able to get on the order of 280 req/sec. By comparison and simple HTML page with nothing but &#8220;Hello World&#8221; served by Apache is just over 600 req/sec. Okay, stage is set (by the way, this was tested on his local machine).</p>
<p><strong>Hello World</strong></p>
<p>How do PHP frameworks score on the &#8220;Hello World&#8221; test? No database calls, just the framework being used in its native tongue to output Hello World. The results were not too good, one of the fastest got just over 120 req/sec, the slowest was 8 req/sec. This is a dramatic difference and of course highlights his argument for performance. Where did Drupal score? Right above 50 req/sec. So not the greatest, but he did make the point that Drupal is not really a framework in the traditional sense. It is a web content management system that can be quickly extended.</p>
<p>So, are there any frameworks that don’t suck? Rasmus did mention that he liked <a href="http://codeigniter.com/">CodeIgniter</a> because it is faster, lighter and the least like a framework.</p>
<p><strong>How to make PHP fast</strong></p>
<p>&#8220;Well, you can’t&#8221; was his quick answer. PHP is simply not fast enough to scale to Yahoo levels. PHP was never meant for those sorts of tasks. &#8220;Any script based language is simply not fast enough&#8221;. To get the speed that is necessary for truly massive web systems you have to use compiled C++ extensions to get true, scaleable architecture. That is what Yahoo does and so do many other PHP heavyweights.</p>
<p><strong>RDF, Semantic Web and the Monkey</strong></p>
<p>RDF in Drupal. Rasmus made a special point of highlighting the importance of embedding structured metadata into the page. RDFa allows you to embed data into your web pages and also lets you create custom vocabularies, or even better, reuse existing vocabularies. Why would you want to do this? Searchmonkey will go out and index this content and open up a rich search API to allow you to do intelligent queries. Well beyond what is possible with traditional search.</p>
<p>Along with rich search you also get enhanced search results. I have blogged about this previously so take a <a href="http://www.sitepoint.com/blogs/2008/03/16/why-rdfa-is-the-only-web-scaleable-metadata-format-for-next-generation-search-engines/">look</a>. It is really cool stuff and I will be discussing it in much more detail over the course of the conference.</p>
<p><strong>Pitching the Semantic Web</strong></p>
<p>What if all Drupal sites had embedded RDFa tags? Well, for one, Yahoo would be very happy. It would play directly into the strengths of Yahoo’s new Semantic Web strategy. They are trying to do interesting things with semantic data but of course they need data — the classic chicken and egg thing.</p>
<p>Rasmus mentioned that Yahoo’s semantic data store can scale to the size of the web so the invitation is open.</p>
<p><strong>The future of Drupal</strong></p>
<p>This is where my focus at Drupalcon is, driving the adoption of semantic technologies within Drupal — I feel that the momentum here will make that a reality. There is a lot of interest, a Semantic Web BoF session was stacked with people with some cool ideas…</p>
<p>More to come.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F12%2Fthanks-rasmus-lerdorf-you-made-my-day.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Team Work: Candidate # 1 for my Book titled “PHP Team Development”</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/10/team-work.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/10/team-work.html#comments</comments>
		<pubDate>Wed, 10 Sep 2008 04:51:20 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[team]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/2008/09/10/team-work.html</guid>
		<description><![CDATA[Team Work!, originally uploaded by annamir ™. I am thinking about using this image for my book title &#8220;PHP Team Development&#8221;. Lets see if I can find anything better. So this one is a candidate for book title photo. Much conceptual I believe, though I fear about the Focus thing.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F10%2Fteam-work.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F10%2Fteam-work.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=development,PHP,team,work&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="flickr-frame"><a title="Photo Title: 'Team Work!' by Photographer annamir ™ on Flickr Phto Sharing Site" href="http://www.flickr.com/photos/annamir/2614830983/"><img class="flickr-photo" src="http://farm4.static.flickr.com/3212/2614830983_99deb2a509.jpg" alt="" /></a></p>
<p><span class="flickr-caption"><a href="http://www.flickr.com/photos/annamir/2614830983/">Team Work!</a>, originally uploaded by <a href="http://www.flickr.com/people/annamir/">annamir ™</a>.</span></div>
<p><span id="more-466"></span></p>
<p class="flickr-yourcomment">I am thinking about using this image for my book title &#8220;PHP Team Development&#8221;. Lets see if I can find anything better. So this one is a candidate for book title photo. Much conceptual I believe, though I fear about the Focus thing.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F10%2Fteam-work.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/09/10/team-work.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert date formats between PHP and MySQL (mm/dd/yyyy to yyyy-mm-dd)</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html#comments</comments>
		<pubDate>Mon, 08 Sep 2008 05:26:16 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[date conversion]]></category>
		<category><![CDATA[date picker]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mm/dd/yyyy]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[yyyy-mm-dd]]></category>
		<category><![CDATA[yyyy-mm-dd hh:mm:ss]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=412</guid>
		<description><![CDATA[I have a view in HWC where I am using Javascript DHTML date picker script to pick the date and insert into test field. By the way HWC is the PHP-MVC (using codeigniter) application I am working on. So as you see, the date pickers default format is mm/dd/yyyy,  which is not acceptable by MySQL [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F08%2Fconvert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F08%2Fconvert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=CodeIgniter,date+conversion,date+picker,javascript,mm%2Fdd%2Fyyyy,MVC,mysql,PHP,yyyy-mm-dd,yyyy-mm-dd+hh%3Amm%3Ass&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I have a view in HWC where I am using Javascript DHTML date picker script to pick the date and insert into test field.  By the way HWC is the PHP-MVC (using codeigniter) application I am working on.</p>
<div id="attachment_446" class="wp-caption alignright" style="width: 310px"><a href="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/09/date_picker_view.jpg"><img class="size-medium wp-image-446" title="DHTML Date Picker View" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/09/date_picker_view-300x164.jpg" alt="Date Picker in dhtml/Javascript " width="300" height="164" /></a><p class="wp-caption-text">Date Picker in dhtml/Javascript </p></div>
<p><span id="more-412"></span>So as you see, the date pickers default format is <strong>mm/dd/yyyy</strong>,  which is not acceptable by MySQL date/time field as it is, so we need a little processing to make MySQL happy enough to store it <img src='http://www.fahdmurtaza.com/myblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Converting  mm/dd/yyyy to yyyy-mm-dd</strong></p>
<p><code>$date=split("/",$_POST['date']);<br />
// where the $_POST['date'] is a value posted by form in mm/dd/yy format<br />
$dated=$date[2]."-".$date[0]."-".$date[1];<br />
// The string dated is now in yyyy-mm-dd format<br />
echo $dated;</code></p>
<p>For example, the date entered through form was 09/02/2009, after processing it will be stored in $dated as 2009-02-09. Pretty kool yeah? Just notice if you have / as  I am happy if helps you. You need help with more similar stuff, post a comment.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F08%2Fconvert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin: Get recent posts within a dynamic wordpress content page or post from 2 different categories</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html#comments</comments>
		<pubDate>Sat, 15 Mar 2008 07:14:16 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[Blogging Engines]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Development Software]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[6seconds.org]]></category>
		<category><![CDATA[fahd]]></category>
		<category><![CDATA[Freedman]]></category>
		<category><![CDATA[Josh]]></category>
		<category><![CDATA[murtaza]]></category>
		<category><![CDATA[stuff]]></category>
		<category><![CDATA[templating]]></category>
		<category><![CDATA[themeing]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html</guid>
		<description><![CDATA[OK I usually work on the wordpress stuff and do all the fancy things with wordpress on these two Blogs of Josh Freedman His press room at http://www.6seconds.org/press/ His blog is at http://6seconds.org/blog/ I spent my times for release and support my plugin. If you like my plugin and enjoy the support, do consider to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F15%2Fwordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F15%2Fwordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=6seconds.org,fahd,Freedman,Josh,murtaza,PHP,Plugins,stuff,templating,themeing,Wordpress&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>OK I usually work on the wordpress stuff and do all the fancy things with wordpress on these two Blogs of Josh Freedman</p>
<p id="pp">His press room at <a href="http://www.6seconds.org/press/" title="Six Seconds helps businesses, schools, communities, and individuals thrive." target="_blank">http://www.6seconds.org/press/</a><br />
His  blog is at  <a href="http://6seconds.org/blog/" target="_blank">http://6seconds.org/blog/</a></p>
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input value="_donations" name="cmd" type="hidden" />
<input value="crutchatl@gmail.com" name="business" type="hidden" />
<input value="Donation - Wp-Multiple Cat Plugin" name="item_name" type="hidden" />
<input value="0" name="no_shipping" type="hidden" />
<input value="1" name="no_note" type="hidden" />
<input value="USD" name="currency_code" type="hidden" />
<input value="0" name="tax" type="hidden" />
<input value="IN" name="lc" type="hidden" />
<input value="PP-DonationsBF" name="bn" type="hidden" />
<input src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" border="0" type="image" /> <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" height="1" width="1" /><br />
</form>
<p>				I spent my times for release and support my plugin. If you like my plugin and enjoy the support, do consider to make a donation to me. Thank you <img src='http://www.fahdmurtaza.com/myblog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . I am available for hire too <img src='http://www.fahdmurtaza.com/myblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can view the plugin working at his press room at <a href="http://www.6seconds.org/press/" title="Six Seconds helps businesses, schools, communities, and individuals thrive." target="_blank">http://www.6seconds.org/press/</a></p>
<p>Its showing the 2 different categories&#8217; recent posts. The number of the posts can be defined in the plugin&#8217;s only php file.<br />
<a href="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/03/image003.jpg" title="Wordpress Plugin: Get recent posts within a dynamic wordpress content page or post"><img src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/03/image003.jpg" alt="Wordpress Plugin: Get recent posts within a dynamic wordpress content page or post" /></a></p>
<p><strong> OK how to do such thing?</strong></p>
<p>I am going to release a modified generic open source version if Josh allows me.</p>
<p><font color="#ff0000">Update</font> 1:33 AM : Yeah he allows me <img src='http://www.fahdmurtaza.com/myblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  so here is the download material (on full post page)..<span id="more-276"></span></p>
<p>Downloads:</p>
<p>Version 0.5  (RAR):   <a href="http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html/wordpress-plugin-get-recent-posts-from-2-categories/" rel="attachment wp-att-279" title="Wordpress Plugin: Get recent posts from 2 categories">Click here to download .rar of WordPress Plugin: Get recent posts from two categories</a></p>
<p>Version 0.5  (RAR):   <a href="http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html/wordpress-plugin-get-recent-posts-from-2-categories-2/" rel="attachment wp-att-280" title="Wordpress Plugin: Get recent posts from 2 categories">Click here to download .zip of WordPress Plugin: Get recent posts from two categories</a></p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F15%2Fwordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/03/15/wordpress-plugin-get-recent-posts-within-a-dynamic-wordpress-content-page-or-post.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mining the Web using PHP</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/03/04/mining-the-web-using-php.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/03/04/mining-the-web-using-php.html#comments</comments>
		<pubDate>Tue, 04 Mar 2008 10:59:32 +0000</pubDate>
		<dc:creator>farhan042</dc:creator>
				<category><![CDATA[data-mining]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Development Software]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[minind]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/2008/03/04/mining-the-web-using-php.html</guid>
		<description><![CDATA[There are many ways for Extracting or fetching desired data or content from an html pages. During my work, i had to build a Miner to get news from multiple sites &#38; update a wordpress blog with the latest news, daily.I had many choices to accomplish this task, few of them are - Regular expressions [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F04%2Fmining-the-web-using-php.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F04%2Fmining-the-web-using-php.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=code,data-mining,minind,open,opensource,PHP,web&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are many ways  for Extracting or fetching desired data or content from an html pages. During my work, i had to build a Miner to get news from multiple sites &amp; update a wordpress blog with the latest news, daily.I had many choices to accomplish this task, few of them are<br />
- Regular expressions<br />
- PHP string functions.<br />
- Using DOM Parsing<br />
- Using Xpath.</p>
<p>First of all i used regular expressions to<span id="more-265"></span> extract data from a static html page.Which was really a nightmare for me.As there is not proper structure of page, it was really hard to extract news from specific tags.Some of them were in Div,some were in TD &amp; others in Li tags. After a long effort i couldn&#8217;t extract data using regular expressions.<br />
I thought to use some html parser, some of them are available on internet.I used it to get data of my choice, even it couldn&#8217;t get desired data, becuase of complexity of structure of page.After that i tried to use PHP string functions, like <em>str_replace</em>,Trim etc, to replace specific tags with known id, so that parsing can get easy. But still, to get desired content, it was really a mess to get to them.</p>
<p>Finally i used firebug to analyze the content of the page, to see the content holders, during which, i cam to find exact XPath location of desired content holder.<br />
XPath (XML Path Language) is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values (strings, numbers, or boolean values) from the content of an XML document. but i wasn&#8217;t aware that Xpath can also be used with html pages, to parse the DOM tree of page.</p>
<p>finally, i got the exact path of Content holder, which had the latest news, daily updated. And i grabbed all the content from it.</p>
<p>I came to conclusion that in case of mining data from web, Xpath proved to be the best &amp; most efficient.</p>
<p>In case of updates, we don&#8217;t need anything, but only the content holder Xpath tree structure of the content &amp; we can get the content in single shot.Regular expression &amp; other ways were very inefficient &amp; time consuming.</p>
<p>Thanks to Farhan for sharing his valuable expertise with us on <a href="http://www.fahdmurtaza.com/myblog/" target="_blank"><em>Fahd Murtaza&#8217;s Blog. </em></a></p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F03%2F04%2Fmining-the-web-using-php.html&amp;layout=standard&amp;show_faces=yes&amp;width=450&amp;action=like&amp;colorscheme=light&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 25px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/03/04/mining-the-web-using-php.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

