Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between ereg_replace() and eregi_replace() function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.38k
    Comment on it

    ereg_replace()

    ereg_replace() function is used to replace regular expression case sensitive.

    Syntax of ereg_replace() is:

     

    string ereg_replace ( string $pattern , string $replacement , string $string)

    It scans string to match pattern, and then replaces the text with replacement. If no string found then it will be returned unchanged.

     

    E.g of ereg_replace() is:

     

    <?php
    $lastname = 'Singh';
    $string = "This is pankaj kumar.";
    $string = ereg_replace('kumar', $lastname, $string);
    echo $string;   
          /* Output: 'This is pankaj Singh.' */
    ?>

     

     

    eregi_replace()

    eregi_replace() function is used to replace regular expression case insensitive.

    Syntax of eregi_replace() is:

     

    string eregi_replace ( string $pattern , string $replacement , string $string )

    This is same as ereg_replace(), but it ignores the case sensitive when matching the strings.

     

    E.g of eregi_replace() is:

    <?php
    
    $string = "Hi this is pankaj.";
    
    print "Output :" .
       eregi_replace("PANKAJ", "Kumar", $string);
    
    /* Output: 'Hi this is Kumar.' */
    ?>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: