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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.