title: PHP preg_replace() upper and lowercase difference
body: <p>I have a PHP/Ajax search function that returns all countries which hold the characters entered in a textbox. All these countries are listed and the given characters are marked bold inside the country it's name in the list. </p>
  
  <p>Example
  Characters given in textbox: "Af"
  Which return <strong>Af</strong> ghanistan and South <strong>Af</strong> rica -
  without the space inbetween ofcourse</p>
  
  <p>Now all the countries names in the database ofcourse start with a uppercase letter. But </p>
  
  <blockquote>
    <p>preg_replace()</p>
  </blockquote>
  
  <p>can not find the difference between Upper and lowercase letters. So when i enter "a" in the textbox it will return Afgh <strong>a</strong> nist <strong>a</strong> n notice the first uppercase "A" not made <strong>bold</strong></p>
  
  <p>Here is the code i am using</p>
  
  <pre><code>$display_name = preg_replace("/" . $search_string . "/", "&lt;b&gt;" . $search_string . "&lt;/b&gt;", $result['Country_Name']);
  $display_url = '';
  
  $output = str_replace('NameReplace', $display_name, $HTML);
  $output = str_replace('UrlReplace', $display_url, $output);
  echo($output);
  </code></pre>
  
  <p>I can "fix" this problem adding the "/i" modifier to the preg_replace() According to PHP.net it will do the following:</p>
  
  <blockquote>
    <p>i (PCRE_CASELESS)
    If this modifier is set, letters in the pattern match both upper and lower case letters.</p>
  </blockquote>
  
  <p>This will turn the <strong>bold</strong> characters inside the countries name lowercase or uppercase according to the characters inside the textbox</p>
  
  <p>example:
  Characters given in textbox: "A" will return "<strong>A</strong> fgh <strong>A</strong> nist <strong>A</strong> n"
  while "a" will return "<strong>a</strong> fgh <strong>a</strong> nist <strong>a</strong> n" again please ignore the white space.</p>
  
  <p>How can i make it that when i enter: "a"
  it will return "<strong>A</strong> fgh <strong>a</strong> nist <strong>a</strong> n" ?</p>
  
  <p>Thank you</p>