I am trying to isolate link from array but in foreach loop it does not work for me.it cosider both elements as a link.
i just want to hyper link google.com and not bakery text but i am getting link on both so if part is not working and its considering bakery as a link.
$services=array('Bakery','www.google.com');
foreach($services as $service):
if (!filter_var($service, FILTER_VALIDATE_URL) === false) {
$service = $service;
} else {
$service = '<a href='.$service.'>'.$service.'</a>';
}
echo $service;
endforeach;