Jump to content

Recommended Posts

I am having trouble trying to fix my eregi call in my script.

 

I have a reporting tool that grabs information from the user agent when they email help questions.  I used eregi to find the string in an array and print out when it finds a match.

 

I don't fully understand the PCRE functions so i don' t know if i am using them right.

 

what i have is

foreach($OSList as $CurrOS=>$Match) {
        // Find a match
        if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
        {
                // We found the correct match
                break;
        }

        
}

 

I know i need to change this around for PCRE preg_match maybe but i am not sure.  if anyone could send me a tutorial or help me out it would be great.

 

EDIT: notice the foreach was not correct

Link to comment
https://forums.phpfreaks.com/topic/227867-eregi-replacement-help/
Share on other sites

oh sorry and thanks.  I actually just found that the script i am using is here

 

http://pastebin.com/qBW6pyzv

 

I did not build the tool it was made by another person.

 

The $Match is the array $oslist  I would like to be able to update this script if anyone can point me in the right direction.

 

Also what it does if i just swap eregi with preg_match is print out the last option in the array.

eregi has been deprecated as of 5.3, you should not use this function.

 

If $match is not a regular expression you should not be using any regex function.

If you do need a regex function then use preg_match.

If you just want to check if $match exists anywhere in the USER_AGENT then use strpos.

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.