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
Does browser understand php?
How to open a file for writing?
How do I debug php?
what is mean by portal
Tell me how can we check the value of a given variable is alphanumeric?
Write a statement to show the joining of multiple comparisons in php?
What is split function in php?
Write logic to print Floyd's triangle in PHP?
What is the Default syntax used in PHP?
What is a http session?
Which functions are used to remove whitespaces from the string?
What is x+ mode in fopen() used for?
What is the difference between mysql_fetch_array() and mysql_fetch_assoc()?
How to pass variables by references?
Explain what does $_files means?