]+class=”[^”]*profile-photo[^”]*”[^>]+src=”([^”]+)”/i’,
‘/]+src=”([^”]+)”[^>]+class=”[^”]*profile-photo[^”]*”/i’,
// General profile image patterns
‘/]+class=”[^”]*pv-top-card-profile-picture__image[^”]*”[^>]+src=”([^”]+)”/i’,
);
foreach ($patterns as $pattern) {
if (preg_match($pattern, $html, $matches)) {
$image_url = $matches[1];
// Clean up the URL if needed
$image_url = html_entity_decode($image_url);
return $image_url;
}
}
return false;
}
function sanitize_url($url) {
return filter_var(trim($url), FILTER_SANITIZE_URL);
}
?>