SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict mmelen's Avatar
    Join Date
    Jul 2005
    Location
    NJ/NY USA
    Posts
    243
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg-replace Function - Word Boundry and Case Insensitive

    How do I add case insensitive feature to the preg_replace function. I read that it is "/i" but exactly where do I add it?

    Code:
    $main[] = "/\b".$row['main']."\b/"; 
    $linkedarticle = preg_replace($main, $keyword, $article, 1);

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $main[] = "/\b".$row['main']."\b/i";
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Salathe
    Software Developer and PHP Manual Author.

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Additionally, preg_quote may come in handy as you're dynamically building your pattern.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Addict mmelen's Avatar
    Join Date
    Jul 2005
    Location
    NJ/NY USA
    Posts
    243
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    Code:
    $main[] = "/\b".$row['main']."\b/i";
    Haha perfect, thanks!


Bookmarks

Posting Permissions

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