![]() |
|
|||||||
| Register | FAQ | Members List | Downloads | Calendar | Today's Posts | Search | Webmaster Resources | Webmaster Blogs |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Here's a handy trick for you to swap values of two variables without using another variable :
Code:
list($a, $b) = array($b, $a); |
|
|||||
|
Here is one other method by which the values can be swaped in all the programing languages:
Quote:
This will also do the work. |
|
||||
|
Another good method, a bit more involved but gets the job done. Here's another method using ^ (XOR) operator :
Code:
<?php $a = 10; $b = 20; echo '$a => ' , $a, ' $b => ', $b, '<br />'; $a = $a ^ $b; $b = $a ^ $b; $a = $a ^ $b; echo '$a => ' , $a, ' $b => ', $b, '<br />'; ?> |
|
|||||
|
i hope following is good method:-
a=a*b; b=a/b; a=a/b; __________________________________________________ _________________ Web Site Design Last edited by garima; 05-29-2008 at 07:25 AM. |
![]() |
| Bookmarks |
| Webmaster Resources |
|
• UK WW SEO Tools • Find UK Hosts |
| The Forum Rules |
|
• Forum Rules - MUST READ |
| Site Of the Month |
![]() Nominate site of the month |
|
|
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |