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
What is implode() in php?
What is use of count() function in php?
Do you know how to delete a file from the system?
What is a namespace in php?
What is composer used for?
What is a php form?
How do I repair phpmyadmin?
What is the difference between $message and $$message in php?
Explain about PHP filter and why it should be used?
Which are the best start and end tags to use?
Explain what is the difference between session and cookie?
How to remove a file?
In PHP, fgets() is used to read a file one line at a time. State Whether True or False?
What is difference between explode() or split() in PHP?
How to write in a file in php?