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 / vivek srivastava
<?php
$a=10;
$b=20;
echo $a,$b;
echo "<br>";
swap($a, $b);
echo "<br>";
echo $a,$b;
function swap(&$a, &$b)
{
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;
}
?>
| Is This Answer Correct ? | 31 Yes | 8 No |
Post New Answer View All Answers
Why do we use in php?
Which function is used to read a single character from a file in PHP.
What are the functions of string?
What are the different tables(engine) present in mysql, which one is default?
What is session and Cokkies . How it works . tell some thing about Session_id()
What are properties in php?
How to include variables in double-quoted strings in php?
What is return value in php?
How do you access a get requests url parameter with php?
Is php easy language to learn?
Write a program to get lcm of two numbers using php?
Does php pass arrays by reference?
What is the difference between for and foreach in php?
Why do we need session?
What are sql functions?