Jump to content

while and for


fer0an

Recommended Posts

hello

I want using while and for in my code anyone can help me?

I want download a webpage using get_content.

this page have 10 sub link and I want them.

so I use this codes :

   //number of website pages
     $i=1;
     while ($i<=4)
     {
//download a webpage
$maincatst = file_get_contents($catlink.$i);
$i++;

//number of sub link in a page
for ($j=1;$j<=10;$j++)

{
// download sub link content
$main_post_str = file_get_contents($link);
}
}

but I can't get them

my result is :

downloaded page 1 and first sub link then page 2 and first sub link ...page 4 and first sublink.

anyone can help me to download page 1 and 10 sub link then ....page 4 and 10 sub link?

 

 

thank you

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.