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 / binoyav

$a = 10;
$b = 20;

echo $a, $b;
echo "<br>";
swap($a, $b);
echo $a, $b;
function swap(&$a, &$b)
{
$temp = $a;
$a = $b;
$b = $temp;
}

Is This Answer Correct ?    79 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in php to find the occurrence of a word in a string?

622


How to assigning a new character in a string?

572


Php error constants and their descriptions

576


Is php 7.0 stable?

504


How to find datatype of variable in php?

520






Does apache use php?

538


What are the php variables?

525


Explain Booleans in PHP?

626


How to Retrieve the Session ID of the Current Session?

526


How to insert a line break in php string?

544


What are static variables in php?

505


write a note on Testing the web site

1412


What is the use of curl()?

627


Tell me what is the use of mysql_real_escape_string() function?

533


What is composer json?

493