Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140817

Can I tell my php function to not execute until the "file_get_contents" has loaded the page using javascript in php code?

$
0
0

This is my php function:

$result = file_get_contents('https://www.example.com/index.php'); 
$regex = '/<img class="pic" src="(.*?)">/';   
preg_match($regex, $result, $matches);
 return($matches[1]);

it's a function to get a picture from that link, sometimes it return the picture, sometimes not, because the image in the site sometimes take seconde to load sometimes not. I want to prevent that from happening in my function, I want to delay the return until the image is loaded, i know this is not possible with php, sleep() didn't help, so I know that I must do it with javascript, but I don't know how to do it, please help ty!


Viewing all articles
Browse latest Browse all 140817

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>