What is the difference between ereg_replace() and eregi_replace()?

What is the difference between ereg_replace() and eregi_replace()?

What is the difference between eregreplace() and eregireplace()?

View Answers

November 15, 2010 at 11:51 AM

Hi all,

In PHP,

ereg_replace ? Replace regular expression case sensitive.

eregi_replace ? Replace regular expression case insensitive.

Example of ereg_replace :

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

Example of eregi_replace :

<?php

$string = "Hi this is deepak.";

print "Output :" .
   eregi_replace("DEEPAK", "Kumar", $string);
/* Output: 'Hi this is Kumar.' */
?>

eregireplace() is case insensitive, while eregreplace() is not.

Thanks









Related Tutorials/Questions & Answers:

Ads