PHP RegEx: Case Insensitive PHP Script


PHP RegEx: Case Insensitive PHP Script

In previous tutorial we match at the beggining of the string given. But that is a case sensitive. If your condition like this: if(preg_match(“/^ABC/”, $string)) then the value of your string “abc”. The script will returned with this message:

No match found

This is because of case sensitive. But in this script we will make the condition insensitive using regex “i” for insensitive. Shown below:

 

 
 
  1. <?php // create a string
  2. $string = 'Ronard';
  3. // try to match our pattern
  4. if(preg_match("/^ron/i", $string)) {
  5. // echo this is it matches
  6. echo 'The string begins with Ron';
  7. } else {
  8. // if not match is found echo this line
  9. echo 'No match found'; }
  10. ?>

 

Even if your string given are ROn, rOn, RoN the script will read insensitive and display the message “The string begins with Ron”.

 

 


Related Post


Edit Multiple Rows in MySQL with Checkbox PHP Scri... Edit Multiple Rows in MySQL with Checkbox PHP Script This code will teach you on how to create an application in PHP that edit multiple rows using ...
CSZ CMS Portal PHP Script Free Download CSZ CMS Portal PHP Script Free Download CSZ CMS is an open source web application that allows to manage all content and settings on the websites. C...
Angry Potato html5 game PHP Script Download Angry Potato html5 gameAngry Potato html5 game ·Touch-- Control the slingshot launch the potato,destroy the pig,and get the starsBe careful not to...
Responsive HTML5, Flash Games & ROMs Games Pl... Responsive HTML5, Flash Games & ROMs Games Platform - Arcade Game Script v1.2.2 PHP Script Our application has been developed to provide the be...
LaraClassified v5.5 (NULLED) – Geo Classifie... LaraClassified v5.5 (NULLED) - Geo Classified Ads CMS PHP Script LaraClassified is the most powerful Classified Ads CMS in the market. An Open Sour...

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

"