file get contents - file_get_contents(): stream does not support seeking PHP


I'm trying to use file_get_contents() to grab only Name from fake name generator site(, however I'm getting the following warning:

file_get_contents() stream does not support seeking 

I dont need entire content of the page. I need only Name section in this site:

My code:

$name= file_get_contents('', NULL, NULL, 849, 32);

Its working well in localhost, showing error only in live website.




You can read about it in the documentation:

Seeking (offset) is not supported with remote files. Attempting to seek on non-local files may work with small offsets, but this is unpredictable because it works on the buffered stream.

What you can do is usesubstr after what you retrive the contents of the page:

$part = substr($name, 849, 32);



This is basically the offset issue in the latest versions

Here we need to change the $offset value from -1 t0 1

  public static function file_get_html( $url, $use_include_path = false, $context = null, $offset = 1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT )



Why are you scraping website? Lots of free APIs are available for fake name generator.


You will get output in JSON format. Decode it using json_decode() and use for your purpose and also it's fast as compared to scraping.

Optional Parameters

The number of names to return, between 1 and 500: 

Limit results to the male or female gender:

Region-specific results:

Require a minimum number of characters in a name:

Require a maximum number of characters in a name:

For JSONP, specify a callback function to wrap results in:

People are also looking for solutions to the problem: php - How can I search for post's 'title','content'&'meta_query' without WP_Query 's'?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.