Jump to content

eregi alternative


jacko310592

Recommended Posts

hey guys,

 

at the moment, i have a code for my site which uses $_SERVER['HTTP_USER_AGENT'] to find the users OS, which goes as follows

 

foreach($OSList as $CurrOS=>$Match)
{
        if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
        {
                break;
        }
}

 

$OSLis is an array with various OS's, each OS in the array is set out like this:

'Windows XP' => '(Windows NT 5.1)|(Windows NT 5.2)|(Windows XP)',

 

as you can see,  to make the match, i am using eregi,  but as this function is going to be removed as of php 6 i was wondering if anyone suggest an alternative to do the same as what i have at the moment.

 

thanks guys

Link to comment
https://forums.phpfreaks.com/topic/192827-eregi-alternative/
Share on other sites

on the same manual page where is says that eregi is deprecated is says:

Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice.

 

The PCRE-extension is documented on:  http://nl2.php.net/manual/en/book.pcre.php

 

so, with version 6.0 you will have to use preg_grep or preg_match or preg_match_all, which (of course) work slightly different from eregi....

Link to comment
https://forums.phpfreaks.com/topic/192827-eregi-alternative/#findComment-1015721
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.