Well I am creating a forum autoposter for IPB board in php and I have to use while statements inside other while statements or foreach statements inside while statements. I use a form containing of website: url, section id, account, password. For each site details are seperated by a ";" And a messages area in the same form. Containing: Title, description, post. Also separated by a ";" So say I want to post 3 messages to 2 forums in the form of: Forum 1: Post message 1, 2, 3 Forum 2: Post messages 1, 2, 3 Since IPB has a flood control I need a 10 second interval between each message posted. I tried this: $urls = explode(";", $_POST['u']); reset($urls); $secs = explode(";", $_POST['s']); $accs = explode(";", $_POST['a']); $psws = explode(";", $_POST['p']); $ttls = explode(";", $_POST['title']); reset($ttls); $ddcs = explode(";", $_POST['desc']); $psts = explode(";", $_POST['Post']); while (list($key, $value) = each($urls)) { while (list($key2, $value2) = each($ttls)) { //Action sleep(10); } } PHP: and this $urls = explode(";", $_POST['u']); reset($urls); $secs = explode(";", $_POST['s']); $accs = explode(";", $_POST['a']); $psws = explode(";", $_POST['p']); $ttls = explode(";", $_POST['title']); reset($ttls); $ddcs = explode(";", $_POST['desc']); $psts = explode(";", $_POST['Post']); while (list($key, $value) = each($urls)) { foreach ($ttls as $key2 => $value2) { //Action sleep(10); } } PHP: But it didn't work. It waited 10 seconds then did all the actions at once. Please help. Thanks.
Unfortunately. As far I can see, that's completely valid and SHOULD wait 10 seconds between each iteration. Dan.
Well I see it in the same way so I tried to test using a simpler method to test. while (list($key, $value) = each($urls)) { foreach ($ttls as $key2 => $value2) { sleep(10); echo "Key: $key2; Value: {$ttls[$key2]}<br />\n"; } } PHP: It waited 10 seconds then everything showed in 1 second :s Edit: Actually say they were 5 titles total it would wait 50 seconds the all 5 lines show.
sleep will wait but the output is buffered - everything will be output at once as the page is only sent to the browser when complete.