Jump to content

multiple str_replace


dreamwest

Recommended Posts

Occasionally i have stings with "?" and " ' " and "," in them

 

How can i get rid of these in one hit

 

Example normal string:

 

$title = "dog walks down path" 

str_replace(' ', '_', trim($title))

Outputs:

dog_walks_down_path

 

Example of string with ? and ' and , in it:

 

$title = "i'd like to see the dog, wouldn't you?" 

str_replace(' ', '_', trim($title))

Outputs:

i'd_like_to_see_the_dog,_wouldn't_you?

 

You can see the problem, i need the output to be:

 

id_like_to_see_the_dog_wouldnt_you

 

Instead of:

 

i'd_like_to_see_the_dog,_wouldn't_you?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/144431-multiple-str_replace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.