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
Do you know how can we check the value of a given variable is a number?
What is Mcrypt used for?
When is a conditional statement ended with an endif?
How to access a Static Member of a Class in PHP?
What is the w3c?
What is framework? How it works? What is advantage?
What is reference variable php?
What does $this do in php?
Explain the difference between mysql_connect and mysql_pconnect?
How does csrf attack work?
Hi this is amul jani here, i complied my graduation in B.com stream.. but as career i looking for PHP language.. to get shape my career. so is that possible to enter in IT world.. for me how much scope of develop my career in this field.. amul jani
What are some of the advanced features of php?
What is array and function?
What is the role of php.ini file?
What are php magic quotes?