Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do you find the length of a string in php?

988


How we can declare variable in php?

968


What is the difference between pop3 IMAP and MAPI?

1066


Tell me how is the ternary conditional operator used in php?

1061


What is the definition of a session?

978


What is the difference between "echo" and "print" in php?

914


Describe PHP error and logging information?

1090


How do I get csrf token?

969


Why is overriding runtime?

997


Does apache use php?

995


Why shouldn't I use mysql_* functions in php?

1083


What is session data?

967


What is difference between post and put in rest?

1014


What is use of header() function in php? What the limitation of header()?

972


Explain the difference between urlencode and urldecode?

1054