DOMDocument : How to get data as string from oboject
i am using the following code :
$doc = new DOMDocument();
$doc->loadHTML($url);
$data = $doc->saveHTML();
preg_match_all("/$k1(.*?)$k2/s",$data,$matches);
and it's generating this error :
Warning开发者_JS百科: preg_match_all() expects parameter 2 to be string, object given in /home/maruf10/public_html/dispatx.php on line 115
it will be helpful if anyone help to find the bug . thanks
change
$data = $doc->saveHTML();
into
$data = (string)$doc->saveHTML();
it should work then.
精彩评论