Sunday, April 27, 2008

Php swap the two variables by reference

<?php

$a =20;
$b =10;
echo $a . $b;
swap(&$a, &$b,$a,$b);  // passing addess and value of the $a,$b
echo "<br>".$a . $b;

function swap($a_ptr,$b_ptr,$a,$b){

$a_ptr = $b;
$b_ptr = $a;


}



No comments:

Post a Comment