<?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; Web Development</title>
	<atom:link href="http://www.fahdmurtaza.com/myblog/category/web-development/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>Javascript &#8211; One of the best Scripts resource</title>
		<link>http://www.fahdmurtaza.com/myblog/2010/09/17/javascript-one-of-the-best-scripts-resource.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2010/09/17/javascript-one-of-the-best-scripts-resource.html#comments</comments>
		<pubDate>Fri, 17 Sep 2010 14:00:49 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/2010/09/17/javascript-one-of-the-best-scripts-resource.html</guid>
		<description><![CDATA[Looking for a cool Web 2.0 Javascript resource. Filled with great examples and downloadable example code, a great javascript resource thats clean as well as useful. Without any long description here is the link. http://www.scriptdeck.co.uk/ Script Deck&#8217;s interface is blog like with top image scroller highlighting the hot tutorials and tips.]]></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%2F2010%2F09%2F17%2Fjavascript-one-of-the-best-scripts-resource.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F09%2F17%2Fjavascript-one-of-the-best-scripts-resource.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Looking for a cool Web 2.0 Javascript resource. Filled with great examples and downloadable example code, a great javascript resource thats clean as well as useful.</p>
<p>Without any long description here is the link. <a href="http://www.scriptdeck.co.uk/">http://www.scriptdeck.co.uk/</a></p>
<p>Script Deck&#8217;s interface is blog like with top image scroller highlighting the hot tutorials and tips.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F09%2F17%2Fjavascript-one-of-the-best-scripts-resource.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/2010/09/17/javascript-one-of-the-best-scripts-resource.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript &#8211; The easiest way to clean-up your JavaScript code</title>
		<link>http://www.fahdmurtaza.com/myblog/2010/07/28/javascript-the-easiest-way-to-clean-up-your-javascript-code.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2010/07/28/javascript-the-easiest-way-to-clean-up-your-javascript-code.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 07:37:58 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[coldfusion javascript php event calendar]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=733</guid>
		<description><![CDATA[Clean-up and beautify your JavaScript code with this online tool]]></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%2F2010%2F07%2F28%2Fjavascript-the-easiest-way-to-clean-up-your-javascript-code.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F07%2F28%2Fjavascript-the-easiest-way-to-clean-up-your-javascript-code.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=coldfusion+javascript+php+event+calendar&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You can use any desktop tool to clean-up and beautify that poorly formated JavaScript you got from a blog or web resource.</p>
<p>I my case I am working on a JavaScript based event calendar that displays a calendar and highlights the current date with the dates which have events associated with them.</p>
<p>I got this great event calendar thats totally based on JavaScript from <a title="JavaScript Event Calnedar" href="http://javascript.about.com/library/blevent1.htm" target="_blank">this link</a> and it was not formatted correctly.  As I had to make a few adjustments to the code as for my needs, I needed it to be correctly formatted so I could work on it.<span id="more-733"></span></p>
<p>So here is how I cleaned that minimized code. Its probably the best and fastest way of doing it.  I opened up this website <a href="http://jsbeautifier.org/">http://jsbeautifier.org/</a> and pasted my javascript code that needed to be cleaned up for editing and just a click on Beautify  and Voila, my code is clean and beautiful.</p>
<p>Don&#8217;t firget visiting back for another JavaScript tip tomorrow. Also if you found this tip useful, you may also find the follwing Tip useful too.</p>
<p><a href="http://www.fahdmurtaza.com/myblog/2010/07/28/javascript-adding-an-pure-javascript-event-calendar-to-your-site.html" target="_self">Adding an pure JavaScript event calendar to your site.</a></p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F07%2F28%2Fjavascript-the-easiest-way-to-clean-up-your-javascript-code.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/2010/07/28/javascript-the-easiest-way-to-clean-up-your-javascript-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript &#8211; Adding an pure JavaScript event calendar to your site.</title>
		<link>http://www.fahdmurtaza.com/myblog/2010/07/28/javascript-adding-an-pure-javascript-event-calendar-to-your-site.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2010/07/28/javascript-adding-an-pure-javascript-event-calendar-to-your-site.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 07:37:26 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=746</guid>
		<description><![CDATA[This tutorial explains how you can add a pure JavaScript event based calendar on your site. You can customize it to your needs too. ]]></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%2F2010%2F07%2F28%2Fjavascript-adding-an-pure-javascript-event-calendar-to-your-site.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F07%2F28%2Fjavascript-adding-an-pure-javascript-event-calendar-to-your-site.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You may find this tutorial very useful if you are looking for a way to do a simple event calendar on your site with no dependency on server side scripting.</p>
<p>Please check<a title="JavaScript event calnedar" href="http://javascript.about.com/library/blevent1.htm" target="_blank"> this simple and elegant way</a> of adding an event calendar on your site.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F07%2F28%2Fjavascript-adding-an-pure-javascript-event-calendar-to-your-site.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/2010/07/28/javascript-adding-an-pure-javascript-event-calendar-to-your-site.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExpressionEngine 2 beta, Wow factor</title>
		<link>http://www.fahdmurtaza.com/myblog/2010/06/15/expressionengine-2-beta-wow-factor.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2010/06/15/expressionengine-2-beta-wow-factor.html#comments</comments>
		<pubDate>Tue, 15 Jun 2010 06:44:22 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Development Software]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=661</guid>
		<description><![CDATA[OK here is the thing. Mohammed, my Boss asked me to work on an application 3 days ago. He wanted to use expression engine and got me a personal license for it. Its a good CMS and has a certain level of customization but something was  missing in the 1.6.9 version we got; yes the [...]]]></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%2F2010%2F06%2F15%2Fexpressionengine-2-beta-wow-factor.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F06%2F15%2Fexpressionengine-2-beta-wow-factor.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>OK here is the thing. Mohammed, my Boss asked me to work on an application 3 days ago. He wanted to use expression engine and got me a personal license for it. Its a good CMS and has a certain level of customization but something was  missing in the 1.6.9 version we got; yes the wow factor.</p>
<p>So he emailed me yesterday and wanted to hear my ideas about expression engine yesterday. I was not sure as I had already started working on expression engine 1.6.9 and had been working on a custom membership management solution and customize it to the level our client needs. We need membership management with custom fields which thankfully comes integrated with the licensed version of expression engine.</p>
<p><strong>Member Management</strong></p>
<p>Build a community with ExpressionEngine’s robust and flexible membership capability.</p>
<p><strong>Multi-User System</strong></p>
<p>ExpressionEngine is a true multi-user system. Each user can be granted a wide range of privileges, letting you define with precise control what each user is permitted to do.</p>
<p><strong>Member Groups</strong></p>
<p>You can define an unlimited number of Member Groups, each with over 40 individual user privileges. Each member of your community is assigned to a Member Group, determining what they are allowed to do.<br />
Custom Member Fields</p>
<p>The member profile system permits you to add your own fields. Build your own data model and collect the information you need from your users.</p>
<p><strong>Member Activation</strong></p>
<p>Members can &#8220;self-activate&#8221; via email or you can validate accounts manually.</p>
<p><strong>Profile Management</strong></p>
<p>Each member has their own profile management page, in which they can set preferences and update their personal information.</p>
<p><strong>Subscription Management</strong></p>
<p>The member console allows your users to manage their comment and gallery subscriptions.</p>
<p><strong>Member Localization</strong></p>
<p>Each member can have their own localization settings, allowing them to view your site in their local time.<br />
Member Communication</p>
<p>An Email Console permits members to email each other from your system. Each user can choose whether or not to receive email.</p>
<p><strong>Email Console Logs</strong></p>
<p>For security, all email sent by your members is logged.</p>
<p><strong>Member Quick Links</strong></p>
<p>Each member that has Control Panel access can view their own custom links in the Control Panel navigation.</p>
<p><strong>Note Pad</strong></p>
<p>Each member has their own notepad.</p>
<p><strong>Member Management</strong></p>
<p>Build a community with ExpressionEngine’s robust and flexible membership capability.</p>
<p><strong>Multi-User System</strong></p>
<p>ExpressionEngine is a true multi-user system. Each user can be granted a wide range of privileges, letting you define with precise control what each user is permitted to do.</p>
<p><strong>Member Groups</strong></p>
<p>You can define an unlimited number of Member Groups, each with over 40 individual user privileges. Each member of your community is assigned to a Member Group, determining what they are allowed to do.Custom Member FieldsThe member profile system permits you to add your own fields. Build your own data model and collect the information you need from your users.Member ActivationMembers can &#8220;self-activate&#8221; via email or you can validate accounts manually.Profile ManagementEach member has their own profile management page, in which they can set preferences and update their personal information.</p>
<p><strong>Subscription Management</strong></p>
<p>The member console allows your users to manage their comment and gallery subscriptions.Member LocalizationEach member can have their own localization settings, allowing them to view your site in their local time.</p>
<p><strong>Member Communication</strong></p>
<p>An Email Console permits members to email each other from your system. Each user can choose whether or not to receive email.Email Console LogsFor security, all email sent by your members is logged.</p>
<p><strong>Member Quick Links</strong></p>
<p>Each member that has Control Panel access can view their own custom links in the Control Panel navigation.</p>
<p><strong>Note Pad</strong></p>
<p><strong> </strong>Each member has their own notepad.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2010%2F06%2F15%2Fexpressionengine-2-beta-wow-factor.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/2010/06/15/expressionengine-2-beta-wow-factor.html/feed</wfw:commentRss>
		<slash:comments>0</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>We don’t mind if you code all night.</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/11/we-don%e2%80%99t-mind-if-you-code-all-night.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/11/we-don%e2%80%99t-mind-if-you-code-all-night.html#comments</comments>
		<pubDate>Thu, 11 Sep 2008 02:14:43 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[day]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[www.hackday.org]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=473</guid>
		<description><![CDATA[They are starting Yahoo Hack Day again. They call it, &#8220;The hack is back!. Do you want to request an invite to Open Hack 2008, September 12-13? Sign up at www.hackday.org. Hope you can join us at Yahoo! HQ in Sunnyvale. We don’t mind if you code all night. &#8220; But the sad news 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%2F11%2Fwe-don%25e2%2580%2599t-mind-if-you-code-all-night.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F11%2Fwe-don%25e2%2580%2599t-mind-if-you-code-all-night.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=day,hack,www.hackday.org,yahoo&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>They are starting Yahoo Hack Day again. They call it, &#8220;The hack is back!. Do you want to request an invite to Open Hack 2008, September 12-13? Sign up at www.hackday.org. Hope you can join us at Yahoo! HQ in Sunnyvale. We don’t mind if you code all night. &#8220;<span id="more-473"></span></p>
<p>But the sad news is that I am in Pakistan, so I can&#8217;t go there to enjoy the event. Anyhow I know its good for the people who will be there for this great learnign opportunity.</p>
<p>Watch the video on full blog post.</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F11%2Fwe-don%25e2%2580%2599t-mind-if-you-code-all-night.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/11/we-don%e2%80%99t-mind-if-you-code-all-night.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>Codeigniter &#8211; Clean URLs &#8211; Apache mod rewrite : Removing /index.php/ from URL in CodeIgniter Application</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 07:09:18 +0000</pubDate>
		<dc:creator>Fahd</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[clean]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[igniter]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[mod rewrite]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[urls]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=417</guid>
		<description><![CDATA[This article discusses how you can enable mod rewrite to work with apache server so you can get those clean urls. CodeIgniter has built in support for clean urls so all you have to do is to activate this using the method described in this article.]]></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%2F08%2F22%2Fcodeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F08%2F22%2Fcodeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html&amp;source=fahdmurtaza&amp;style=compact&amp;space=2&amp;hashtags=.htaccess,clean,code,CodeIgniter,igniter,mod,mod+rewrite,permalinks,rewrite,urls&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><em><strong>Note: Based on its popularity, updated on 6th june 2011 to clean up code for easy copy paste.</strong></em></p>
<p>OK readers, here is a simple method to achieve clean urls with your PHP application developed in CodeIgniter.</p>
<p>Please note that this method is applicable only to applications developed in CodeIgniter. Much of the content has been taken from CodeIgniter wiki but rewritten in my own way.</p>
<p>This article explains how to take away &#8220;index.php&#8221; from your CI application URLs. However, it does NOT remove the need for Index.php, which is the CI front controller i.e. even though Index.php will not appear in the URL, it still needs to be present at the top level of your site (above the /system/ directory).  To quote the User Guide,</p>
<p>You can easily remove this file by using a .htaccess file with some simple rules.</p>
<p>You need to perform the following steps to get this working:</p>
<ol>
<li>Create a .htaccess file to configure the rewrite engine</li>
<li>Set $config['index_page'] to an empty string</li>
<li>Make sure your apache uses the mod_rewrite module</li>
<li>Make sure apache is configured to accept needed .htaccess directives</li>
<li>Restart apache and test</li>
</ol>
<h2>1. Create your .htaccess file</h2>
<p>Create a new file named .htaccess and put it in your web directory</p>
<pre class="brush: plain">
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#&#039;system&#039; can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn&#039;t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

# If we don&#039;t have mod_rewrite installed, all 404&#039;s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php</pre>
<p>Notes for Windows users:<br />
To create this file you must open Command Prompt and type:</p>
<pre class="brush: plain">copy con .htaccess [Enter]
[Press CTRL + Z]</pre>
<p>A blank .htaccess file will be created. Now you can edit it using Notepad or your favorite text editor and copy the script above.</p>
<p>Note: Most Windows editors will assume that you are attempting to save an .htaccess file as a file with an extension and no filename. The Crimson Editor can be used to create and save .htaccess files and other files that have no filename.</p>
<p>Note: If your site is placed in subfolder specify the path in the &#8220;RewriteBase /subfolder/&#8221; line.</p>
<h2>2. Set $config['index_page'] to an empty string</h2>
<p>Open your</p>
<p>system/application/config/config.php</p>
<p>and find the line that assigns $config['index_page'] a value, usually:</p>
<pre class="brush: plain">$config[&#039;index_page&#039;] = &amp;amp;amp;quot;index.php&amp;amp;amp;quot;;</pre>
<p>and change it to:</p>
<pre class="brush: plain">$config[&#039;index_page&#039;] = &#039;&#039;;</pre>
<p>Save the file.</p>
<h2>3. Make sure your apache has mod_rewrite activated</h2>
<p>This means that the apache must be configured to load the mod_rewrite module (or it might have it compiled-in). For module inclusion, usually you have to look for a line like this in httpd.conf or a file loaded by it (hint: use some quick file search utility to grep files with lines containing &#8216;rewrite&#8217; string):</p>
<pre class="brush: plain">
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
</pre>
<p>If you&#8217;re running Apache2 type</p>
<pre class="brush: plain">
a2enmod
</pre>
<p>in the console and when prompted</p>
<pre class="brush: plain">
rewrite
</pre>
<p>to enable mod_rewrite.</p>
<p>On a Windows machine this line might look this way:</p>
<pre class="brush: plain">
LoadModule rewrite_module modules/mod_rewrite.so
</pre>
<p>If it is commented out (# in front), make sure to uncomment it and save the file. Checking if the corresponding module exists may be a good idea as well (but it usually does).</p>
<h2>Make sure apache accepts needed .htaccess directives</h2>
<p>This means that apache is explicitly configured to allow .htaccess files to override those directives that you use in your .htaccess file from step 1. above.</p>
<p>It seems to be sufficient if you add these two lines to your  section where you configure the document root for your CI application:</p>
<pre class="brush: plain">#...
Options FollowSymLinks

AllowOverride FileInfo
#...</pre>
<p>There might be other Options listed, just make sure you have FollowSymLinks as well.</p>
<p>Should you get a 500 Internal Server Error, try the following syntax:</p>
<pre class="brush: plain">Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all</pre>
<h2>5. Restart apache and test your application</h2>
<p>Works? Congratulations!</p>
<p>Doesn&#8217;t work? Ehrrr… well, do not give up; equip yourself with patience, double check all steps above and if it still does not work, post on the forum giving all details of your setup.</p>
<h2>How does URL rewriting work?</h2>
<pre class="brush: plain">
&amp;amp;amp;lt;IfModule mod_rewrite.c&amp;amp;amp;gt;
...
&amp;amp;amp;lt;/IfModule&amp;amp;amp;gt;
</pre>
<p>Do what is inside only if Apache has the mod_rewrite feature (by in place compilation, or loaded module).</p>
<pre class="brush: plain">RewriteEngine On</pre>
<p>Activate the URL rewriting engine, if not already done (in main Apache configuration file.</p>
<pre class="brush: plain">RewriteBase /</pre>
<p>Define the part of the URL that won&#8217;t change nor be used for rewriting. In fact, this part will be removed before processing, and prepended after processing. This&#8217;s a good way to use subfolder-independent rewrite rules. For example, if your CodeIgniter index.php is placed in a virtual host directory, like /tests/, set RewriteBase to /tests/.</p>
<pre class="brush: plain">RewriteCond %{REQUEST_FILENAME} !-f</pre>
<p>Condition to meet for RewriteRule activation. Here, we test if the requested filename does not exist.</p>
<pre class="brush: plain">
RewriteCond %{REQUEST_FILENAME} !-d
</pre>
<p>Same as above, but we test for directory existence.</p>
<pre class="brush: plain">RewriteRule ^(.*)$ index.php/$1 [L]</pre>
<p>If RewriteCond conditions are met, this rule will be applied. It inserts index.php before the requested URI. The $1 represents the part of string enclosed by parentheses in left expression. The [L] means that this rule is the last one if rule is applied (thus stopping rewriting).</p>
<h2>Configuring mod_rewrite in the httpd.conf file</h2>
<p>The Apache mod_rewrite docs say</p>
<p>While URL manipulations in per-server context are really fast and efficient, per-directory rewrites are slow and inefficient. If you have access to your httpd.conf file, you&#8217;ll have better performance if you configure the rewrite rules in there.</p>
<p>You can add something like this to your httpd.conf:</p>
<pre class="brush: plain">RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]</pre>
<p>Configuring mod_rewrite and virtual hosting with Apache 2.2</p>
<pre class="brush: plain">ServerName www.mydomain.com
DocumentRoot /path/to/ci/directory

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]</pre>
<p>Credits: http://codeigniter.com/wiki/mod_rewrite/</p>

<p class="FacebookLikeButton"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F08%2F22%2Fcodeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.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/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

