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

What are the two types of variables?

975


How to find a substring from a given string in php?

1023


What is the difference between overloading and overriding in php?

1033


How big is nvarchar max?

1001


What are the benefits of using queries?

1140


Which is better php or nodejs?

951


What is the difference between php traits vs interfaces?

964


Explain include(), include_once, require() and require_once?

1012


Is age nominal or ordinal?

940


What is uniqid php?

1044


Explain whether it is possible to share a single instance of a memcache between multiple php projects?

966


How long will it take to learn php?

974


Tell me how can we automatically escape incoming data?

922


What is php mean?

1023


Is salary a ratio or interval?

1005