To replace both strings in one statement, do the following;
<?php
$find = array(" ", "&");
$replace = array("-", "and");
$string = "Hello I am a man & I have a dog";
echo str_replace($find, $replace, $string); //Output: Hello-I-am-a-man-and-I-have-a-dog
http://codepad.org/nGj26mNc
A more elegant way would be to have one associative array. (http://codepad.org/OgogWK5l)
<?php
$findAndReplace = array(" " => "-", "&" => "and");
$string = "Hello I am a man & I have a dog";
echo str_replace(array_keys($findAndReplace), array_values($findAndReplace), $string);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…