1. Write a function to swap two values ?
$a = 10;
$b = 20;
echo $a, $b;
swap(); // If u want u can pass parameters
echo $a, $b; // It should print 20 , 10
Answer Posted / binoyav
$a = 10;
$b = 20;
echo $a, $b;
echo "<br>";
swap($a, $b);
echo $a, $b;
function swap(&$a, &$b)
{
$temp = $a;
$a = $b;
$b = $temp;
}
| Is This Answer Correct ? | 80 Yes | 6 No |
Post New Answer View All Answers
What is php and its uses?
How to open a file in php?
How to merge values of two arrays into a single array?
What is difference between print and echo in php?
What is meant by session in php?
Xplain is it possible to use com component in php?
Can we use include ("xyz.php") two times in a php page "index.php"?
What are the differences between php constants and variables?
What is the purpose of php?
What are the differences between GET and POST methods?
What is difference between mysqli and mysql?
What does the initials of php stand for?
Define about declare construct?
How to convert numbers to strings in php?
Explain the difference between unlink() and unset()?