SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    replace both upperCase and lowerCase

    Code:
    code
    
    $myVar = 'abcdABCD';
    
    $myVar=str_replace('a','', $myVar);
    
    echo $myVar;
    
    result
    
    bcdABCD
    The code above replace 'a'.
    I like to replace both "a" and "A" at a time.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Use str_ireplace() — The case-insensitive version of str_replace().
    http://php.net/manual/en/function.str-ireplace.php

    Code PHP:
    $myVar = 'abcdABCD';
    $myVar=str_ireplace('a','', $myVar);
    echo $myVar;
    result
    bcdBCD

  3. #3
    Non-Member
    Join Date
    Sep 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use:

    $myVar=str_replace('a','', $myVar);
    $myVar=str_replace('A','', $myVar);

    This will replace both a and A


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
  •