Jump to content


Photo

how to change everything in a string?


  • Please log in to reply
2 replies to this topic

#1 iainlang

iainlang
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 19 June 2006 - 10:33 AM

I need to know how to change every comma in a string to a space and i'm not having a lot of luck with strstr() I don't seem to understand. it any ehlp, thanx

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 19 June 2006 - 10:43 AM

strstr() is used to find first occurrence of a string within a string. You will have better luck with str_replace(). You can use it like so: str_replace(","," ",$string);

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 June 2006 - 10:44 AM

should be able do that easily with str_replace
$str = "This has,commas,init";

$str = str_replace(',', ' ', $str);

echo $str;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users