PDA

View Full Version : replacing dot


FrEaKmAn
August 14th, 2007, 09:19 PM
Hi

Can I somehow replace dot(.) in php somehow? I'm always getting errors...

MishY
August 14th, 2007, 09:26 PM
You didn't say where the dot was causing you problems.

str_replace (http://uk3.php.net/manual/en/function.str-replace.php)

FrEaKmAn
August 14th, 2007, 11:06 PM
for example

str_replace('.', '-', $text);

oracle128
August 15th, 2007, 10:08 AM
That syntax works fine for me. What error are you getting?

FrEaKmAn
August 15th, 2007, 08:33 PM
sorry, I put wrong example, so here is the part of my script


function convert_symbols($var){
$chars = array(
":" => "-", ";" => "-", "_" => "-", "/" => "-", "+" => "", "%" => "", "&" => "",
"$" => "", "€" => "", "@" => "", "{" => "", "}" => "", "(" => "", ")" => "", "#" => "",
"?" => "", " " => "-", "-----" => "-", "----" => "-", "---" => "-", "--" => "-");
return strtolower(str_replace(array_keys($chars),$chars,$ var));
}


I can't put dot into ""

oracle128
August 16th, 2007, 07:30 AM
Using your function, I still had no problem using a period as either the character to be replaced (array key), or the replacement (array value).

FrEaKmAn
August 17th, 2007, 01:01 PM
Using your function, I still had no problem using a period as either the character to be replaced (array key), or the replacement (array value).

it seems I messed something up elsewhere, thanks anyway