PHP removing commas, stops, questionmarks... from string -


this question has answer here:

let's have string this:

$string = "i have big, nice, green house!?" 

what want remove characters ', . ! ? : "" ''' string.

how this? tryed rtrim() function, able remove 1 kind of characters not of them.

use str_replace() array of special character -

$string = "i have big, nice, green house!?";  echo $content = str_replace(['.', ',', '?', '!'], '', $string); 

output

i have big nice green house

or if want remove of them try regex -

echo $content = preg_replace('/[^a-z0-9\s]/i', '', $string); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -