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 php session start?
Do you know what is php?
What is the difference between null and empty?
How to take a substring from a given string in php?
Is php a programming language?
What are session variables in php?
What is difference between readonly and constant?
What are the php variables?
Why is php so popular?
What is the difference between super () and this ()?
What are psrs?
How come the code works, but doesn’t for two-dimensional array of mine?
How to replace a substring in a given string?
What will the ?getdate() function returns in PHP?
What is laracast?