Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-14-2010, 02:46 AM Need help again
grafitti's Avatar
Novice Talker

Posts: 9
Trades: 0
Ok, I'd like to know how do I make a number stay the same for a certain amount of times for example.

PHP Code:
$i 0;
//I'd like for 0 to repeat 4 times and then resume to number 1
while($i 10)
{

echo 
$i;
$i++;


I tried putting a -4 but, It echo's out like -4 -3 -2 etc.. I'd rather 0's though.
grafitti is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-14-2010, 11:19 AM Re: Need help again
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Is this what you're going for?
PHP Code:
$x 0;
$total 0;
$count 0;
while(
$total 10)
{
     if(
$count == 4)
     {
          
$x++;
          
$count 0;
     }
     echo 
$x;
     
$total++;
     
$count++;

This is a less clear, but shorter way to do the same thing:
PHP Code:
$d .25;
$x 0;
$total 0;
while(
$total 10)
{
     echo (int) 
$x;
     
$x += $d;
     
$total++;

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-15-2010, 07:22 PM Re: Need help again
grafitti's Avatar
Novice Talker

Posts: 9
Trades: 0
Thanks, It's somewhat but I figured it out.
grafitti is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help again
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40735 seconds with 12 queries