...

View Full Version : String Mystery



gorilla1
11-12-2002, 02:27 PM
I have a string $element="xxxxxx". I wish to change the second character from 'x' to 'p'. Seems like this should work:
substr_replace($element,"P",1,1);

But this makes no change at all. Why not?

G

mordred
11-12-2002, 02:42 PM
The new string value is returned instead of working directly on the string.



$element = "xxxxxx";
$element = substr_replace($element, "P", 1, 1);
echo $element;

gorilla1
11-12-2002, 02:53 PM
Right... Thanks!

G



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum