Jump to content

[solved]Wildcard in php


me1000

Recommended Posts

I have a browser detection script, and i want the user to be prompted if they are using IE (any version)

so here is what i have so far..

[code]if ( $client_data['browser'] == "Microsoft Internet Explorer". *)[/code]

the * is a wildcard character in everything else i have ever used. thats just the opening, i have the rest of it but there was no need to post it.

so basically if anything at all follows the Microsoft Internet Explorer then it needs execute the if command.


Thanks,
Link to comment
https://forums.phpfreaks.com/topic/33138-solvedwildcard-in-php/
Share on other sites

[code=php:0]
if (preg_match('/^Microsoft Internet Explorer/', $client_data['browser'])){
[/code]

or the slightly faster alternative, though it doesn't force "Microsoft Internet Explorer" to be at the front of the string...

[code=php:0]
if (strstr($client_data['browser'], 'Microsoft Internet Explorer')){
[/code]

there might be alternative solutions as well
Link to comment
https://forums.phpfreaks.com/topic/33138-solvedwildcard-in-php/#findComment-154407
Share on other sites

Don't think there is.

You need to use something like:
[code]
<?php
$browser = get_browser(null, true);
if (preg_match('/Internet Explorer/', $browser['parent']))
{
//what ever you are doing
}
?>
[/code]

You will have to check what $browser['parent'] actually outputs for IE I know for FF it says 'Firefox' but what ever it does put that string in where I put MSIE and you shoudl be fine.
Link to comment
https://forums.phpfreaks.com/topic/33138-solvedwildcard-in-php/#findComment-154411
Share on other sites

[quote author=genericnumber1 link=topic=121295.msg498350#msg498350 date=1168116631]
[code=php:0]
if (preg_match('/^Microsoft Internet Explorer/', $client_data['browser'])){
[/code]

or the slightly faster alternative, though it doesn't force "Microsoft Internet Explorer" to be at the front of the string...

[code=php:0]
if (strstr($client_data['browser'], 'Microsoft Internet Explorer')){
[/code]

there might be alternative solutions as well
[/quote]

Thank you!

it works fine now! :)
Link to comment
https://forums.phpfreaks.com/topic/33138-solvedwildcard-in-php/#findComment-154418
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.