How to swap values between two variables without using a
third variable?

Answer Posted / sriram

Hey guys, what about swaping variables contains string
values? All of your solutions will suck... Try this and swap
any datatype without third variable... Happy Sensible Coding..

$v = 'sriram';
$u = 'lakshmi';

$v .= $u;
$u = substr($v,0,(strlen($v) - strlen($u)));
$v = substr($v,(strlen($v) - strlen($u)-1), strlen($v));

echo 'u = ' . $u .'<br>';
echo 'v = ' . $v;

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)

2226


what is an INI file?

1593


what is log files in qtp what is use

1584


What is the difference between WebIntelligence and Designer in creating universes?

1464


when we use mantis? how learn mantis?

1684






How to merge Action Form with Dyna Action Form in Struts.

1894


In mainframe SDSF, Can we copy the list of jobs currently executing in SDSF in to a seperate DATASET...?

1844


Hello...has anyone interviewed with Information Management Services(IMS)located in Silver Spring MD??If yes,what can you share about the programming test and the analytical test?

1501


Please forward important interview and basic questions in VB6 on my email id: usneha_16@yahoo.co.in

1569


WHAT IS MAIN IMPORTANT THING IN SOFTWARE?

1718


I am taking the bmc control m/enterprise manager 7.0 scheduling test and just wanted to see what kind of questions they would ask or if anyone has taken the test and how long it is for how many questions?

5661


In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?

1608


What sysoption determines where the macro facility searches a specific catalog for complied macro?

1647


What is BASIS

1661


What is autocall macro and how to create autocall macro? what is the use of it?

1490