How can conditional statements like strstr() be applied to filter and extract specific information from the user agent string in PHP?

To filter and extract specific information from the user agent string in PHP, you can use conditional statements like strstr() to check for certain substrings within the user agent string. By using strstr() or similar functions, you can identify specific keywords or patterns in the user agent string and extract relevant information based on those conditions.

$userAgent = $_SERVER['HTTP_USER_AGENT'];

if(strstr($userAgent, 'Chrome')){
    echo "User is using Chrome browser.";
} elseif(strstr($userAgent, 'Firefox')){
    echo "User is using Firefox browser.";
} else {
    echo "User agent information not recognized.";
}