thinzar
thinzar

Reputation: 1550

stripping character from mysql result

I want to move some char eg.(/,\,/t..etc) from mysql result. Can I strip every char with one function? I want to know this function.Help me!

Upvotes: 0

Views: 143

Answers (2)

soulmerge
soulmerge

Reputation: 75704

You can replace the occurences with the empty string, str_replace() allows you to do multiple replace operations at once:

$string = str_replace(array("\t", '/', '\\'), '', $string);

Upvotes: 2

Matthew Scharley
Matthew Scharley

Reputation: 132254

To remove a set of characters from a string:

function removeBadCharacters($input) {
    // removes '/', '\\' '\t'
    return preg_replace("@[".preg_quote("/\\\t", '@')."]@g", '', $input);
}

Upvotes: 0

Related Questions