<?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; Strings</title>
	<atom:link href="http://www.dhavest.com/category/phptutorial/php-strings/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>
		<item>
		<title>Getting a single character in a string</title>
		<link>http://www.dhavest.com/2007/10/09/getting-a-single-character-in-a-string/</link>
		<comments>http://www.dhavest.com/2007/10/09/getting-a-single-character-in-a-string/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 04:44:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.dhavest.com/2007/10/09/getting-a-single-character-in-a-string/</guid>
		<description><![CDATA[This snippet of code will show how to get individual character from a string in a variable
$sMyName = &#8220;Darwin&#8221;;
print $sMyName[1]; // will print the letter &#8220;a&#8221;
]]></description>
			<content:encoded><![CDATA[<p>This snippet of code will show how to get individual character from a string in a variable</p>
<p>$sMyName = &#8220;Darwin&#8221;;</p>
<p>print $sMyName[1]; // will print the letter &#8220;a&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dhavest.com/2007/10/09/getting-a-single-character-in-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use heredoc in PHP</title>
		<link>http://www.dhavest.com/2007/10/09/how-to-use-heredoc-in-php/</link>
		<comments>http://www.dhavest.com/2007/10/09/how-to-use-heredoc-in-php/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 04:13:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.dhavest.com/2007/10/09/how-to-use-heredoc-in-php/</guid>
		<description><![CDATA[Heredoc also known as here-document is a way of specifying string literals or printing them literally without the use of quotes to threat them as literal strings. Heredoc preserves the line breaks and other whitespace (including indentation) in the text.
Heredocs start with &#60;&#60;&#60; and a token or also known as delimiting identifier. The token or [...]]]></description>
			<content:encoded><![CDATA[<p>Heredoc also known as here-document is a way of specifying string literals or printing them literally without the use of quotes to threat them as literal strings. Heredoc preserves the line breaks and other whitespace (including indentation) in the text.</p>
<p>Heredocs start with <tt>&lt;&lt;&lt;</tt> and a token or also known as delimiting identifier. The token or delimiting identifier  don&#8217;t leading or trailing whitespace and followed by semicolon a to end the statement.</p>
<p>Example: We wanted to print this string</p>
<pre><font color="#008000">The quick brown fox</font></pre>
<pre><font color="#008000">jumps over the lazy dog.</font></pre>
<pre><font color="#008000">But what is the name of that dog </font></pre>
<pre><font color="#008000">whom the fox jumped over.</font></pre>
<p>Usually we will use the print built in function of php and put line breaks to separate the lines</p>
<pre><font color="#008000">print "The quick brown fox \n";</font></pre>
<pre><font color="#008000">print "jumps over the lazy dog. \n";</font></pre>
<pre><font color="#008000">print "But what is the name of that dog \n"; </font></pre>
<pre><font color="#008000">print "whom the fox jumped over \n";</font></pre>
<p>In heredoc we literally print these sequence string without having to print all the lines 1 by 1;</p>
<p>Using heredoc</p>
<pre><font color="#008000">print &lt;&lt;&lt; DOGS
</font></pre>
<pre><font color="#008000">The quick brown fox</font></pre>
<pre><font color="#008000">jumps over the lazy dog.</font></pre>
<pre><font color="#008000">But what is the name of that dog </font></pre>
<pre><font color="#008000">whom the fox jumped over.</font></pre>
<pre><font color="#008000">DOGS; </font></pre>
<p><strong>Heredocs in HTML</strong></p>
<pre><font color="#008000">$sAnimal = "cat";</font></pre>
<pre><font color="#008000">$aZoo = array("elephant","zebra","monkey","lion","bear");</font></pre>
<pre><font color="#008000">print &lt;&lt;&lt; ZOO</font></pre>
<pre><font color="#008000">There are different animals in the zoo.</font></pre>
<pre><font color="#008000">It includes &lt;b&gt;$aZoo[1], $aZoo[3].&lt;/b&gt;</font></pre>
<pre><font color="#008000">There are also &lt;font color="red"&gt;$sAnimal&lt;/font&gt; here.</font></pre>
<pre><font color="#008000">ZOO;</font></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dhavest.com/2007/10/09/how-to-use-heredoc-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
