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 ? | 79 Yes | 6 No |
Post New Answer View All Answers
What is the difference between $var and $$var?
Why php is widely used?
What's the difference between __sleep and __wakeup?
What are the rules in creating php variable?
How do I see how many pages per session in google analytics?
Which is better session or cookie?
What is the scope of a variable defined outside a function?
What are soundex() and metaphone() functions in php?
Is php better than java?
How to get the ip address of the client?
Is php used for frontend or backend?
What is difference between isset and empty in php?
What is the use of strpos in php?
How to test if a variable is an array?
In how many ways we can retrieve the data in the result set of mysql using php?