<?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>Simply Dhavest - Filipino PHP Programmer &#187; Arrays</title>
	<atom:link href="http://www.dhavest.com/category/phptutorial/php-arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dhavest.com</link>
	<description>Journal of a Filipino Programmer</description>
	<lastBuildDate>Fri, 29 Jan 2010 14:23:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Convert array to string</title>
		<link>http://www.dhavest.com/2007/10/19/convert-array-to-string/</link>
		<comments>http://www.dhavest.com/2007/10/19/convert-array-to-string/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 07:21:20 +0000</pubDate>
		<dc:creator>conai</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[implode]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.dhavest.com/2007/10/19/convert-array-to-string/</guid>
		<description><![CDATA[Problem: You want to convert an array to string so that it is easier to print the result instead of looping inside the array and have this printed
Old Solution:
$aArr = array("Have you ever seen",
"the beauty of the world.",
"The wonderful creation of the Lord." );
foreach($aArr as $sString) {
    print $sString;
}
Other Solution:
$aArr = array("Have [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong> You want to convert an array to string so that it is easier to print the result instead of looping inside the array and have this printed</p>
<p><strong>Old Solution:</strong></p>
<pre>$aArr = array("Have you ever seen",</pre>
<pre>"the beauty of the world.",</pre>
<pre>"The wonderful creation of the Lord." );</pre>
<pre>foreach($aArr as $sString) {</pre>
<pre>    print $sString;</pre>
<pre>}</pre>
<p><strong>Other Solution:</strong></p>
<pre>$aArr = array("Have you ever seen",</pre>
<pre>"the beauty of the world.",</pre>
<pre>"The wonderful creation of the Lord." );</pre>
<pre>$sString = implode(" ", $aArr);</pre>
<pre>print $sString;</pre>
<p><strong>In Action:</strong> I want to execute a linux command via PHP and get its result and extract the desire content. The example below will try to extract the ip address from the ifconfig command</p>
<pre>exec("ifconfig", $aOutput);</pre>
<pre>$sTempString = implode(" ", $aOutput);</pre>
<pre>preg_match("/inet\saddr:(.*?)\s/i", $sTempString, $aMatch);</pre>
<pre>print $aMatch[1]; //</pre>
<p><!--adsense--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dhavest.com/2007/10/19/convert-array-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
