User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,771 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,518 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1434 | Replies: 7
Reply
Join Date: Dec 2004
Location: Utha
Posts: 1
Reputation: Jakester_101 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jakester_101 Jakester_101 is offline Offline
Newbie Poster

Need help with php

  #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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 16
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Need help with php

  #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  
Join Date: Aug 2004
Location: India
Posts: 40
Reputation: varunrathi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
varunrathi's Avatar
varunrathi varunrathi is offline Offline
Light Poster

Solution Re: Need help with php

  #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  
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

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

Re: Need help with php

  #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  
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

  #6  
Dec 8th, 2004
mikeandike22,
did you read the question?
Reply With Quote  
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: Need help with php

  #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  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 101
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Need help with php

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC