Need help with php

Reply

Join Date: Dec 2004
Posts: 1
Reputation: Jakester_101 is an unknown quantity at this point 
Solved Threads: 0
Jakester_101 Jakester_101 is offline Offline
Newbie Poster

Need help with php

 
0
  #1
Dec 7th, 2004
hi ive been workingon some For loops an While Loops and Switch statements and i need so help with this one problem if you could help me that would be grate ive tried realy hard to do this on my own but cant figure it out thanks for helping

This is the frist one i need help with is how to print this uesing For loops

13579
1357
135
13
1


and this other one by useing If/Else i think

I have..........10 exercise routines left for the month!
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Need help with php

 
0
  #2
Dec 7th, 2004
I think you should post in the programming section designated for php coding you would probably get more hits. It is in the forum index underneath scripting languages.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 41
Reputation: varunrathi is an unknown quantity at this point 
Solved Threads: 1
varunrathi's Avatar
varunrathi varunrathi is offline Offline
Light Poster

Re: Need help with php

 
0
  #3
Dec 8th, 2004
u must do something about ur programming concept. i meam, if u find this prog. to be tough then what about the tougher ones that are waiting for u in the near future.
to print the following format using for loop
13579
1357
135
13
1

u can take help of a nested loop
first start a for loop (say i) from (1 to c), where c=9, in the first case
and then inside that for loop create anothe for loop from (say j) (1 to i)
and now print j and outside the j loop print a new line and the decrease the value of c. i leave this on u. think by how much the value of c should be decrease to get the desired output.
best of luck!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

 
0
  #4
Dec 8th, 2004
while we're on the topic of scripting languages, here's a dirty hack in python:
  1. l = []
  2. for i in range(1,10):
  3. if i % 2 != 0:
  4. l.append(i)
  5. for i in range(1,6)[::-1]:
  6. print "".join([str(x) for x in l[0:i]])
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Need help with php

 
0
  #5
Dec 8th, 2004
serfurj what are you talking about that is totally irrelevant
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

 
1
  #6
Dec 8th, 2004
mikeandike22,
did you read the question?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

 
1
  #7
Dec 8th, 2004
i'm not sure how my post is totally irrelevant. perhaps i shouldn't have said that we're on the "topic" of scripting languages, but instead that this is a thread in the c/c++ forum and i'm continuing with the off-forum-topic discussion.

anyways, that python code prints what you want. if you know python it will probably help you out when writing the php code.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Need help with php

 
0
  #8
Dec 8th, 2004
I think serfurj's post is completely on-topic, as it gives the OP an idea of how it's done in another language, so they're not being spoon-fed. Sounds like an excellent answer to me...
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 2014 | Replies: 7
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC