quick links

Swap number without or with third variable

Swap number without third variable.

<?php
$a=12;
$b=15;
$a=$a+$b;
$b=$a-$b;
$a=$a-$b;
echo $a."<br />".$b;
?>

OUTPUT:
$a=15
$b=12

Swap number with third variable.

<?php
$a=12;
$b=15;
$c=$a;
$a=$b;
$b=$c;
echo $a."
".$b;
?>

OUTPUT:
$a=15
$b=12

 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK