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

$a=10;
$b=10;
list($a,$b) = array($b, $a);
echo "a=" . $a;
echo "b=" . $b;

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Gd PHP?

580


Is php class name case sensitive?

508


What are the functions of string?

515


What is delimiter php?

527


How to download and install php on windows?

601






Does session expire on closing browser?

485


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

506


What are the array functions in php?

520


Which is the best web server?

524


Is there an easy way to delete an element from a php array?

473


What is rtrim php?

543


How to reset/destroy a cookie in php?

525


Why are sessions used?

526


How to check a variable is an array or not in php?

504


Which method removes the last element from the end of an array?

490