Faqts : Business : Programming : Shopping For You : PHP : Function Libraries : String

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 25 people (92%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can I remove all instances of a character from a string?

Jan 24th, 2000 21:35
Nathan Wallace, Donovan J. Edye, Jason Brooke


You need to use str_replace():

    http://www.php.net/manual/function.str-replace.php3

Here is a quick example:

    $str = 'abcde';
    $str_minus_a = str_replace("a", '', $str);  // bcde

For more string functions see:

    http://www.php.net/manual/ref.strings.php3