You can pull out the first URL of the exploded list, blow it up and write it back to the file:
while($urls = explode('|', file_get_contents('urls.txt'))) {
$first_url = array_shift($urls);
file_put_contents('urls.txt', implode('|', $urls));
function1($first_url);
}
Do you expect this process to be interrupted? If not, it makes sense to simply assume that all URLs will be processed, and an empty file when the program is completed:
foreach (explode('|', file_get_contents('urls.txt') as $url) {
function1($url);
}
file_put_contents('urls.txt', '');
source
share