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 / ramse
One way is:
function swap($x, $y) {
$x ^= $y ^= $x ^= $y;
return array($x,$y);
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
How do you check if an arraylist is empty?
Is uploaded file php?
How to get the value of current session id?
What is php and its advantages?
How many ways to include array elements in double-quoted strings using php?
What is variable function php?
Why are sessions used?
How to download files from an external server with code in php?
How to convert strings to upper or lower cases?
Is php a framework?
What is the default session time in php?
How to check curl is enabled or not in PHP
What is singleton pattern in php?
What is new static in php?
How can we determine whether a variable is set?