I have the following array
I want to be able to replace "Dog" to "<b>DOG</b>"PHP Code:$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
I tried str_replace but it didn't work.
Please help.PHP Code:str_replace("dog", "<b>DOG</b>", $a);
I have the following array
I want to be able to replace "Dog" to "<b>DOG</b>"PHP Code:$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
I tried str_replace but it didn't work.
Please help.PHP Code:str_replace("dog", "<b>DOG</b>", $a);
Is it possible to make any value in an array the first one?
I have this array:
I want to move horse or cat so it is the first valuePHP Code:$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
PHP Code:$a=array("c"=>"Horse","a"=>"Dog","b"=>"Cat");
$a=array("b"=>"Cat","a"=>"Dog","c"=>"Horse");
Probably why the str_replace didn't work is because you need to have it actually match what you are searching and replacing (you could probably use Regular expressions for this, but for your example use the following).
Notice how I matched the case in the str_replace function to that of the word "Dog" in the array. The above snippet (spelling?) will produce the following:Code:$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); $string = str_replace('Dog', '<b>DOG</b>', $a); echo $string;
Hope this helps.DOG
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Bookmarks