<?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>SydneyFX - A Web Designer Blog &#187; PHP</title>
	<atom:link href="http://www.sydneyfx.com.au/wordpress/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sydneyfx.com.au/wordpress</link>
	<description>Ramblings of a Freelance Web Designer &#38; Developer</description>
	<lastBuildDate>Mon, 19 Jul 2010 08:58:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Remove Spaces from a String using PHPt.</title>
		<link>http://www.sydneyfx.com.au/wordpress/remove-spaces-from-a-string-using-php/41</link>
		<comments>http://www.sydneyfx.com.au/wordpress/remove-spaces-from-a-string-using-php/41#comments</comments>
		<pubDate>Fri, 23 Jun 2006 14:47:04 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sydneyfx.com.au/wordpress/?p=41</guid>
		<description><![CDATA[This is quite a funny one for me. As you may or may not know I&#8217;m not a guru PHP developer but I do know a little from my time as a web designer/developer. Today I had to do something &#8230; <a href="http://www.sydneyfx.com.au/wordpress/remove-spaces-from-a-string-using-php/41">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is quite a funny one for me. As you may or may not know I&#8217;m not a guru PHP developer but I do know a little from my time as a web designer/developer. Today I had to do something as simple as removing spaces from a variable string using PHP.</p>
<p>After a quick think about how I was going to do this I put together some code that would remove the spaces.</p>
<p>$mobile = &#8221;  0400 000 000&#8243;;<br />
//echo $mobile;<br />
$mobile = trim($mobile);<br />
$numcount = strlen($mobile);<br />
//echo $numcount;<br />
$ptr=0;</p>
<p>while ($i &lt;= $numcount) { //Loop until testing of all numerals in ph no<br />
if ($mobile{$ptr} != &#8221; &#8220;) {<br />
$ptr++;<br />
}else{<br />
$mobiletemp = substr($mobile, 0, $ptr);<br />
echo &#8220;mobiletemp:&#8221;.$mobiletemp.&#8221;\n&#8221;;<br />
$mobile = $mobiletemp.substr($mobile,($ptr+1),$numcount);<br />
echo &#8220;mobile :&#8221;.$mobile;<br />
$ptr++;<br />
};<br />
$i++;<br />
}</p>
<p>So here I was really proud of myself for cooking up such an elaborate chunk of code that would do what I needed. During the process of writing the code I posted a question on a developer forum asking for a quick way of removing the spaces. By the time I finished my piece of code I had a response from the developer forum.</p>
<p>And here was their solution</p>
<p>$mobile = str_replace ( &#8216; &#8216;, &#8221;, $mobile );</p>
<p>That&#8217;s right. Just one line of code to do the same thing as my 18 lines of code. Same solution different method.<br />
Hopefully someone who like me needs to know how to do this in a hurry and will find this post.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt.', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.sydneyfx.com.au%2Fwordpress%2Fremove-spaces-from-a-string-using-php%2F41&amp;title=Remove+Spaces+from+a+String+using+PHPt." title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.sydneyfx.com.au/wordpress/remove-spaces-from-a-string-using-php/41/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
