How to read HTML source of a URL into a string and implode() by tag in PHP

1 Answer

0 votes
$html = implode('<div>', file('http://www.example.com/'));

echo $html;


/*
run: 

<html>
<head>

<body>


<!doctype html>
<div><html>
<div><head>
<div>    <title>Example Domain</title>
<div>
<div>    <meta charset="utf-8" />
<div>    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<div>    <meta name="viewport" content="width=device-width, initial-scale=1" />
<div>    <style type="text/css">
...

*

 



answered Jun 16, 2016 by avibootz

Related questions

1 answer 251 views
2 answers 367 views
2 answers 261 views
1 answer 276 views
1 answer 210 views
1 answer 229 views
...