Hello I use preg_match_all function to grab things on a page but when i tried to grab some specific parts like details part it sends me an array !
code structure on that page is
<div class="f slp">DETAILS I WANT TO GET</div>
previously for grab urls n titles I used a code like
//so this gets URLs in href=""
preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$scraped,$results);
but this time I want to grab some details on that page under the structure of
<div class="f slp">DETAILS I WANT TO GET</div>
preg_match_all("#<div class=\"f slp\">(.*?)<\/div>#si", $source, $match);
foreach($match[1] as $val) {
echo $val."<br>";
}
Please check out PHP Simple HTML DOM Parser a very easy to use library that makes it pretty easy to extract content from html.
// from the documentation
$html = str_get_html("<div>foo <b>bar</b></div>");
$e = $html->find("div", 0);
echo $e->tag; // Returns: " div"
echo $e->outertext; // Returns: " <div>foo <b>bar</b></div>"
echo $e->innertext; // Returns: " foo <b>bar</b>"
echo $e->plaintext; // Returns: " foo bar"
read more in manual