while and for

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fer0an
Forum Newbie
Posts: 12
Joined: Sat Jan 23, 2010 8:15 am

while and for

Post by fer0an »

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 :

Code: Select all

//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
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: while and for

Post by Bind »

Post Reply