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 / dinesh kumar
function swap($x,$y)
{
$x^=$y^=$x^=$y;
return array($x,$y);
}
list($a,$b)=swap(5,10);
echo $a;
echo $b;
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
what is the use of include_once in php?
What does $this do in php?
Explain what are psrs? Choose 1 and briefly describe it?
What's the difference between using mysql_ functions and pdo?
What is the difference between html and php?
How to redirect a url from http to https in .htaccess?
How does php work with apache?
Tell me whether it is possible to share a single instance of a memcache between multiple php projects?
Why sessions are used in php?
What is variable and data type?
Tell me what sized websites have you worked on in the past?
What are the rules for naming a php variable?
Do you know how can php and html interact?
What are the different ways to login to a remote server?
How to pass variables by references?