PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 5th, 2000, 11:44 AM
Tom Denise Tom Denise is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 3 Tom Denise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello to All,
I'm stuck and I need your assistance(if I may).

OK here goes:
$i=1; while ($i <= 5) { echo("$i,"); $mylink=("$i"); $i++; }

Here is the problem. If I echo the $i string, I get 1,2,3,4,5 as a result,
which is exactly what I should get.
BUT... if I assign $mylink to the $i variable and I try echoing $mylink, only the last number of $i is printed. I would like to make it so the assigned variable $mylink will print the same contents as the $i.
Thanks
Regards, Tom...



Reply With Quote
  #2  
Old April 5th, 2000, 01:45 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
I'm not sure what you're asking here. Each iteration of the loop reassigns $mylink to the current value of $i so it follows that it would contain the last value of $i in the iteration. Each time you are echoing $i it is only printing the current value followed by a comma. $i NEVER equals 1,2,3,4,5 which is what you seem to imply.

Perhaps this is what you want (BTW, please break your code up into something legible)

$mylink="";
for ($i=1;$i<=5;$i++)
{
$mylink.="$i,";
}
print $mylink;

Reply With Quote
  #3  
Old April 6th, 2000, 04:35 AM
Tom Denise Tom Denise is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 3 Tom Denise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Rod, thank you for your immediate response.
It worked like a charm...
Regards,
Tom
ps.I will try to make my code
more legible next time.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > arrays and variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT