943,363 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2323
  • PHP RSS
Dec 7th, 2004
0

Need help with php

Expand Post »
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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jakester_101 is offline Offline
1 posts
since Dec 2004
Dec 7th, 2004
0

Re: Need help with php

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.
Reputation Points: 33
Solved Threads: 19
Nearly a Posting Virtuoso
mikeandike22 is offline Offline
1,496 posts
since May 2004
Dec 8th, 2004
0

Re: Need help with php

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!
Reputation Points: 10
Solved Threads: 1
Light Poster
varunrathi is offline Offline
41 posts
since Aug 2004
Dec 8th, 2004
0

Re: Need help with php

while we're on the topic of scripting languages, here's a dirty hack in python:
PHP Syntax (Toggle Plain Text)
  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]])
Reputation Points: 32
Solved Threads: 2
Light Poster
serfurj is offline Offline
35 posts
since Dec 2004
Dec 8th, 2004
0

Re: Need help with php

serfurj what are you talking about that is totally irrelevant
Reputation Points: 33
Solved Threads: 19
Nearly a Posting Virtuoso
mikeandike22 is offline Offline
1,496 posts
since May 2004
Dec 8th, 2004
1

Re: Need help with php

mikeandike22,
did you read the question?
Reputation Points: 32
Solved Threads: 2
Light Poster
serfurj is offline Offline
35 posts
since Dec 2004
Dec 8th, 2004
1

Re: Need help with php

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.
Reputation Points: 32
Solved Threads: 2
Light Poster
serfurj is offline Offline
35 posts
since Dec 2004
Dec 8th, 2004
0

Re: Need help with php

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...
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: I need help with a form please
Next Thread in PHP Forum Timeline: Access PostgreSQL from PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC