PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
qwik
Forum Newbie
Posts: 2 Joined: Fri Apr 15, 2011 4:34 pm
Post
by qwik » Fri Apr 15, 2011 4:40 pm
Hi, I would like to transfer
eregi in this code:
Code: Select all
if ( eregi( 'index.php\?', $row->link ) ) {
if ( !eregi( 'Itemid=', $row->link ) ) {
$row->link .= '&Itemid='. $row->id;
}
}
to
preg_match , because I am getting errors like:
Deprecated: Function eregi() is deprecated in C:\wamp\www ....
Any help is appreciated.
Zlobcho
Forum Newbie
Posts: 18 Joined: Sun Jun 21, 2009 7:57 pm
Post
by Zlobcho » Fri Apr 15, 2011 9:39 pm
Hi,
Your ereg regex is very simple
Code: Select all
if (preg_match('/index\.php\?/i', $row->link)) {
if (!preg_match('/itemid\=/i', $row->link)) {
$row->link .= '&Itemid='. $row->id;
}
}
You do not need both if's, they can be combined into one with &&
qwik
Forum Newbie
Posts: 2 Joined: Fri Apr 15, 2011 4:34 pm
Post
by qwik » Sat Apr 16, 2011 2:48 pm
Thanks man, it's working perfect!