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
How to find the index of an element in an array php?
Are php session secure?
What is a php trait?
What is php session id?
Is empty function c++?
What does $this do in php?
Tell me how to get the value of current session id?
Explain object-oriented methodology in php?
What is reference variable php?
Which php framework is best for beginners?
How to remove values saved in the current session?
Can the value of a constant change during the script's execution?
How to set session.gc_divisor properly?
What are super global variables in php?
How to include variables in double-quoted strings in php?