Page 1 of 1

[Solved]A newbie question: changing eregi() to preg_match()?

Posted: Mon Jun 07, 2010 7:55 am
by insodoneva
Please help me with changing eregi() to preg_match().
Here is the code I need to change:

Code: Select all

if ( eregi( 'index.php\?', $row->link ) ) {
                  if ( !eregi( 'Itemid=', $row->link ) ) {
                     $row->link .= '&Itemid='. $row->id;
                  }
               }
             break;
Any help will be appreciated!

Re: A newbie question: changing eregi() to preg_match()?

Posted: Mon Jun 07, 2010 10:09 am
by Jonah Bron
You're not using any regex, so preg_match() is unnecessary. Use strpos().

Code: Select all

if (strpos($row->link,  'index.php?') !== false) {
                  if (strpos($row->link, 'Itemid=') === false) {
                     $row->link .= '&Itemid='. $row->id;
                  }
               }
             break;
Edit: Oh yeah, huh? :)

Re: A newbie question: changing eregi() to preg_match()?

Posted: Mon Jun 07, 2010 10:14 am
by markusn00b
Jonah Bron wrote:You're not using any regex, so preg_match() is unnecessary. Use strpos().

Code: Select all

if (strpos($row->link,  'index.php\?') !== false) {
                  if (strpos($row->link, 'Itemid=') === false) {
                     $row->link .= '&Itemid='. $row->id;
                  }
               }
             break;
You'll want to take out that back-slash, too. ;)

Re: A newbie question: changing eregi() to preg_match()?

Posted: Mon Jun 07, 2010 1:56 pm
by insodoneva
10Q so much guys! your wonderful!!! :D :D :D :drunk:
U just saved my crashing site :mrgreen: