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 / ankush sharma

<?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 ?    14 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many different types of messages available in php?

1058


Which is faster for or foreach php?

1000


Explain me what is the use of 'print' in php?

995


How do I run a php script in windows?

1081


What is the goto statement useful for?

1049


Explain briefly about a search-friendly site looks like?

959


How to remove the new line character from the end of a text line?

1046


How do you end a session in php?

1146


Explain what is the static variable in function useful for?

994


What are php strings?

1031


What is difference between include,require,include_once and require_once()?

1135


List some of the features of php7.

1040


What is the different between count() and sizeof() in php?

988


Explain setcookie() function in php?

1069


What is scope of variable in php?

1111