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

Why do we use in php?

932


Which function is used to read a single character from a file in PHP.

995


What are the functions of string?

936


What are the different tables(engine) present in mysql, which one is default?

970


What is session and Cokkies . How it works . tell some thing about Session_id()

1908


What are properties in php?

922


How to include variables in double-quoted strings in php?

915


What is return value in php?

929


How do you access a get requests url parameter with php?

961


Is php easy language to learn?

1009


Write a program to get lcm of two numbers using php?

911


Does php pass arrays by reference?

1023


What is the difference between for and foreach in php?

973


Why do we need session?

907


What are sql functions?

899