You can validate a LinkedIn profile URL in PHP using regular expressions. Here is an example of how to do this:

phpCopy code<?php

function validate_linkedin_url($url) {
    $pattern = "/(http(s)?:\/\/)?([w]{3}.)?linkedin.com\/((in\/[a-zA-Z0-9-]+)|(pub\/[a-zA-Z0-9-]+))/";
    if (preg_match($pattern, $url)) {
        return true;
    }
    return false;
}

$url = "https://www.linkedin.com/in/example";
if (validate_linkedin_url($url)) {
    echo "Valid LinkedIn URL";
} else {
    echo "Invalid LinkedIn URL";
}

?>

This code uses the preg_match function to match the LinkedIn profile URL against a regular expression pattern. If the URL matches the pattern, the function returns true, otherwise it returns false.

You can modify the regular expression pattern to fit your specific requirements. This is just an example of how to validate a LinkedIn profile URL in PHP.

(Visited 6 times, 1 visits today)
Was this article helpful?
YesNo
Close Search Window