Results 1 to 5 of 5

Thread: str_replace

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    str_replace

    Are str_replace and preg_replace case sensitive?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Believe so *looks at the docs*

  3. #3
    str_replace:
    [email protected]
    27-May-2001 11:58

    It should be noted in the docs that str_replace() is Case Sensitive. This
    makes sense of course, as that is the quickest way to solve problems. It
    would be interesting to see something like stri_replace(), an insensitive
    replace. Hmm..(goes to check CVS)

  4. #4
    ...and preg_replace:
    [email protected]
    19-Apr-2002 10:04

    If you want to quote strings case insensitively, without altering the case
    of the actual match (like google does) :

    $text = "Reading the documentation is allways recommanded, and the
    PHP manual is worth a read";
    $search = "read";
    $text =
    preg_replace("'$search'i","<b>\\0</b>",$text);

    /*
    * will output :
    * <b>Read</b>ing the documentation is allways
    * recommanded, and the PHP manual is
    * worth a <b>read</b>.
    *
    */

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    damn, then how can you do a normal case insensative replace?
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width