I have created a function where I need to extract URL from content. I don’t know where did I go wrong. Here’s my code..
function strip_url_content($content){
$strip = explode("n", esc_html($content));
foreach($strip as $key => $single){
if (!filter_var($single, FILTER_VALIDATE_URL) === true) {
unset($strip[$key]);
}
}
return implode( ' ', $strip );
}