28, May 2012

how to swap two variables in one line - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: how to swap two variables in one line
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: how to swap two variables in one line  (Read 1826 times)
Cyberpunk Wannabe
*
Gender: Male
Posts: 39
172 credits
Members referred : 0



« on: Sep 13, 2005, 09:25:46 pm »

I know this is a nerd thing, but here it is :

Code:
<?php
$a 
30;
$b 50;

$a = ( $a $b ) - ( $b $a );

echo 
$a " " $b;
?>


It works only with numeric variables.
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Sep 14, 2005, 11:23:02 am »

Hehe.  Cool

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Novice Spammer
***
Posts: 100
103 credits
Members referred : 0



« Reply #2 on: Sep 27, 2005, 11:00:02 am »

Hahah thats tight.
I wish I was an Oscar winner
**
Posts: 86
247 credits
Members referred : 0



« Reply #3 on: Oct 03, 2005, 12:44:23 am »

Hehe. It sounds like a geek joke Smiley

Very smart
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #4 on: Oct 03, 2005, 04:41:35 pm »

But that is 4 lines of code!

Only teasing... great stuff!


Last blog : Canonical URL Links / Tags
I wish I was an Oscar winner
**
Posts: 86
247 credits
Members referred : 0



« Reply #5 on: Oct 03, 2005, 04:47:17 pm »

But that is 4 lines of code!

Only teasing... great stuff!

Actually it is only one : $a = ( $a + $b ) - ( $b = $a );
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #6 on: Oct 03, 2005, 04:57:04 pm »

HAHA... I know! I was teasing...

<?php
1. $a = 30;
2. $b = 50;

3. $a = ( $a + $b ) - ( $b = $a );

4. echo $a . " " . $b;
?>

Sorry if my sense of humour is a bit corny, you'll get to know me! I also stir a lot too.


Last blog : Canonical URL Links / Tags
I wish I was an Oscar winner
**
Posts: 86
247 credits
Members referred : 0



« Reply #7 on: Oct 03, 2005, 05:00:57 pm »

Hehehe. This was a rushed post.

Next time I will read more carefully, and I will sleep more at night Smiley
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=210
Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: how to swap two variables in one line
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 08:29:57 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.852
Total Topics: 11.033
Total Members: 21.457
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: kenyon

116 Guests, 2 Users online :

22 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.