Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$txt = "Doctor";
$str_replsace = str_replace(" ", "+", $txt);
$content = file_get_contents("https://www.bbc.co.uk/search?q=$str_replsace");
preg_match_all('/<a [^>]+><span aria-hidden="false">([^<]+)<\/span><\/a>/im', $content, $matches);
$titles= array_unique($matches[1]);
//var_dump($titles);
foreach ($titles as $title) {
echo $title . PHP_EOL;
}
?>