file_get_contents function inside the loop

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
peravino
Forum Newbie
Posts: 1
Joined: Fri May 06, 2016 7:42 am

file_get_contents function inside the loop

Post by peravino »

Hi

When i use the file_get_contents function to retrive data from multiple url by using while loop, the codei works fine but it loads very slow. Can any one know what is the problem on my php code?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: file_get_contents function inside the loop

Post by Celauran »

It's a blocking request, so it's bound to be slow. Consider looking at curl_multi or Guzzle for asynchronous requests.
Post Reply