Friday, August 28, 2015

Variable swap

/*
 * variable swap
 * */
$a = 7;
$b = 8;
$i = $a;
$a = $b;
$b = $i;
echo $a , $b;

/*
 * another way to variable swap
 * */
$a = 25;
$b = 30;
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;
echo $a, $b;

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }