Q:

Write a PHP program to swap two variables

0

Write a PHP program to swap two variables.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$a = 15;
$b = 276;
echo "\nBefore swapping:  ". $a . ',' . $b;
list($a, $b) = array($b, $a);
echo "\nAfter swapping:  ". $a . ',' . $b."\n";
?>

Sample Output:

The number before swapping is:                              
Number a =15 and b=27                                       
The number after swapping is:                               
Number a =27 and b=15

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now