How to parse an entire web page in php / single line?

How to parse an entire web page in php / single line?

Use file_get_contents instead of file.

Here is an example.

1
2
$url = 'http://google.com';
$lines = file_get_contents($url);

If you want to parse a single certain line from a web page, here is a code example.

2
3
4
$url = 'http://google.com';
$content = file($url);
$certain_ine = $content[153];

It will echo the content from line 153 from google.com.

Add a comment: