File_get_contents (): stream does not support PHP search

I'm trying to use file_get_contents () to grab only the name from the fake name generator site ( https://fakena.me/fake-name/ ), however I get the following warning:

file_get_contents() stream does not support seeking 

I do not need all the content on the page. I only need the "Name" section on this site: https://fakena.me/fake-name/ .



My code is:

 $name= file_get_contents('https://fakena.me/fake-name/', NULL, NULL, 849, 32); 

It works well in the local host, showing an error only on the website.

+2
source share
1 answer

You can read about it in the documentation :

Search (offset) is not supported by deleted files. Trying to search non-local files may work with small offsets, but this is unpredictable because it works with a buffered stream.

What you can do is use substr after you extract the contents of the page:

 $part = substr($name, 849, 32); 
+2
source

Source: https://habr.com/ru/post/1015601/


All Articles