note 86090 modified in function.str-ireplace by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Example for str_ireplace(). It will print "RePlaCeMe" in red color, but after this, it would be written in lower case because of the string $search.

<?php

$search  = 'replaceme';
$replace = '<font color="#FF0000">'.$search.'</font>';
$text    = 'Please RePlaCeMe, OK?';

echo str_ireplace($search, $replace, $text);

?>

Example for ext_str_ireplace(). It will print "RePlaCeMe" in red color, and will not change the capitalization:

<?php

$search  = 'replaceme';
$replace = '<font color="#FF0000">$1</font>';
$text    = 'Please RePlaCeMe, OK?';

echo ext_str_ireplace($search, $replace, $text);

?>

--was--
Sorry, I made a misstake at the code example below.

Example for str_ireplace(). It will print "RePlaCeMe" in red color, but after this, it would be written in lower case because of the string $search.

<?php

$search  = 'replaceme';
$replace = '<font color="#FF0000">'.$search.'</font>';
$text    = 'Please RePlaCeMe, OK?';

echo str_ireplace($search, $replace, $text);

?>

Example for ext_str_ireplace(). It will print "RePlaCeMe" in red color, and will not change the capitalization:

<?php

$search  = 'replaceme';
$replace = '<font color="#FF0000">$1</font>';
$text    = 'Please RePlaCeMe, OK?';

echo ext_str_ireplace($search, $replace, $text);

?>

http://php.net/manual/en/function.str-ireplace.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.