Nick
2006.01.08, 03:34 AM
I need to write a PHP function that will search through a string, replacing all instances of '!and!' with &. I've tried a few things, and this looks like it should work... but it doesn't. Can anyone help me with this?
function replace_and_signs($some_text)
{
$new_text = $some_text;
$pos = strpos($new_text, '!and!');
while($pos > 0)
{
substr_replace($new_text, '&', $pos, 5);
$pos = strpos($new_text, '!and!');
}
return $new_text;
}
function replace_and_signs($some_text)
{
$new_text = $some_text;
$pos = strpos($new_text, '!and!');
while($pos > 0)
{
substr_replace($new_text, '&', $pos, 5);
$pos = strpos($new_text, '!and!');
}
return $new_text;
}