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
insodoneva
Forum Newbie
Posts: 4 Joined: Mon Jun 07, 2010 7:50 am
Post
by insodoneva » Mon Jun 07, 2010 7:55 am
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!
Last edited by
insodoneva on Mon Jun 07, 2010 2:40 pm, edited 2 times in total.
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Mon Jun 07, 2010 10:09 am
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?
Last edited by
Jonah Bron on Mon Jun 07, 2010 10:24 am, edited 1 time in total.
markusn00b
Forum Contributor
Posts: 298 Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England
Post
by markusn00b » Mon Jun 07, 2010 10:14 am
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.