<?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; Variables</title>
	<atom:link href="http://www.dhavest.com/category/phptutorial/php-variables/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>Swapping variables without using temporary variable</title>
		<link>http://www.dhavest.com/2007/10/11/swapping-variables-without-using-temporary-variable/</link>
		<comments>http://www.dhavest.com/2007/10/11/swapping-variables-without-using-temporary-variable/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 11:59:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Variables]]></category>

		<guid isPermaLink="false">http://www.dhavest.com/2007/10/11/swapping-variables-without-using-temporary-variable/</guid>
		<description><![CDATA[For example we wanted to swap two variable values given
$x = 10;
$y = 20;
The usual way of exchanging their variables is to use a temporary variable like the one below
$x = 10;
$y = 20;
$z = $x; // $z will be equal to 10 now which will serve as a temporary variable
$x = y; // $x [...]]]></description>
			<content:encoded><![CDATA[<p>For example we wanted to swap two variable values given</p>
<pre><font color="#008000">$x = 10;</font></pre>
<pre><font color="#008000">$y = 20;</font></pre>
<p>The usual way of exchanging their variables is to use a temporary variable like the one below</p>
<pre><font color="#008000">$x = 10;</font></pre>
<pre><font color="#008000">$y = 20;</font></pre>
<pre><font color="#008000">$z = $x; // $z will be equal to 10 now which will serve as a temporary variable</font></pre>
<pre><font color="#008000">$x = y; // $x will be equal to 20 now
</font></pre>
<pre><font color="#008000">$y = $z; // $y will be 10 now</font></pre>
<p>Their is another way to do this without using temporary variable is the use of list() function</p>
<pre><font color="#008000">$x = 10;</font></pre>
<pre><font color="#008000">$y = 20; </font></pre>
<pre><font color="#008000">list($x, $y) = array($y, $x);</font></pre>
<p>You can also do this in multiple variables</p>
<pre><font color="#008000">$sDog1 = "Boston Terrier";</font></pre>
<pre><font color="#008000">$sDog2 = "American Bulldog";</font></pre>
<pre><font color="#008000">$sDog3 = "German Shepperd";</font></pre>
<pre><font color="#008000">$sDog4 = "Great Dane";</font></pre>
<pre><font color="#008000">list($sDog1, $sDog2, $sDog3, $sDog4) = array($sDog3, $sDog1, $sDog4, $sDog2); </font></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dhavest.com/2007/10/11/swapping-variables-without-using-temporary-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
