How do I ignore casing in Preg_match?

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

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do I ignore casing in Preg_match?

Post by simonmlewis »

Code: Select all

if (preg_match('/t shirt/', $row->description))
{  
echo "Description: T Shirt<Br/>";
}
I'm trying to see how to find t shirt and T Shirt in a field. I've heard of the "i modifier" but don't know how to implement it in my code... or if there is a better way to run this query. So far I have over 200 results, so anything to make it better would be good too.

Thanks.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I ignore casing in Preg_match?

Post by Celauran »

Code: Select all

preg_match('/pattern/i', $variable);
Post Reply