Jump to content

PHP loops


BlackSparrow

Recommended Posts

Did PHP a few years ago and for the life of me i can't work out why this doesn't work:

 

for ( $counter2=1; $counter2 < 1000; $counter2++) 
{
   for ( $counter1=1; $counter1 < 1000; $counter1++) 
   {
      echo "Fixed bug";
   }
}

 

and yet this does

 

for ( $counter2=1; $counter2 < 100; $counter2++) 
{
   for ( $counter1=1; $counter1 < 100; $counter1++) 
   {
      echo "Fixed bug";
   }
}

 

 

I tested it because I have a rather large amount of data to retrieve from an XML file and i kept receiving errors

Link to comment
Share on other sites

the first code sample is essentially looping 1,000,000 times..

 

You're in essence outputting

 

10^6*strlen('fixed bug');

 

which obviously will be ALOT of data, its a little over 8mb, which could be timing out for you..

 

the php code is obviously good.. Also, your server may be preventing you from sending files bigger than a certain amount (many servers do have this limitation.. especially shared hosting, mostly to prevent file sharing and media streaming)

 

but if it is NOT that problem, than, I hope you can find a solution here at PHPFreaks :)

Link to comment
Share on other sites

Oh ok well I basically have 1000 rows and each row has 10 columns.

 

I would like to be able to collect this data from the xml file and display it (use it in list boxes etc)

 

so I figured this would be a way of doing that (obviously not the two loops above but a loop to go over all rows and another nested loop to go though the cells).

 

But if it a file size return issue (I'm just running this on a test account at award space so its very possible that it is and thanks for pointing that out to me) then I wonder how I can get around it?

 

Link to comment
Share on other sites

You can possibly contact the support for your web hosting, as you're a shared hosting I'm more than sure you don't have access to modify apache config files, etc..

 

I don't think your web hosting will lift this limitation, as on shared hosting you're not the only 1 using that 1 installation of apache, However, its still a good idea to talk to them, as it could be something else (dunno what else, but its always possible)..

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.