Hi I've been trying to understnad preg for a while now and don't know where I am going wrong with this: <?php function getweb($website) { if(!$ch = curl_init($website)) { echo "Could not connect to $website"; return; } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_HEADER, 0); $output = curl_exec($ch); curl_close ($ch); return $output; } $total = getweb('http://www.thewebmasterstool.com/'); $match_expression = '/<title>(.*?)\/<\/title>/i'; preg_match($match_expression,$total,$matches); $asd = strip_tags($matches[1]); echo $asd; ?> PHP: Thanks
Remove this between the <title> tags: \/ This would match a forward slash followed by the </title> tag, which is most likely causing the error. Other than that, it works.