Peace, I tried to replace a string with a string:

<?php
$Msg=$_POST['Msg'];
$arrA=array(' ' ,'-red' ,'-blue' ,'-green' );
$arrB=array('</font>','<font color=red>','<font color=blue>','<font color=green>');
$Msg_B=str_replace($arrA,$arrB,$Msg);
echo $Msg_B;
?>

It works well, but if someone typed "-rEdasddsadasda cccc" not "-redasddsadasda cccc"
or "-REDasddsadasda cccc" or anything like that how will my program slove this problem?
The text which I want to become like this:"asddsadasda cccc"

why don't you set the string to all lower case.

<?php
$Msg=$_POST['Msg'];
$Msglower = strtolower($Msg);
$arrA=array(' ' ,'-red' ,'-blue' ,'-green' );
$arrB=array('</font>','<font color=red>','<font color=blue>','<font color=green>');
$Msg_B=str_replace($arrA,$arrB,$Msglower);
echo $Msg_B;
?>

or you could try preg_replace

Thanks for your reply, I want the text normally typed, what is preg_replace?Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.