faqts : Computers : Programming : Languages : PHP : Common Problems : Strings

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

4 of 5 people (80%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

How do I replace : with chr(0) using eregi_replace?

Mar 23rd, 2001 19:12
Ben Udall, mike gifford, http://www.php.net/manual/en/function.eregi-replace.php


eregi_replace refuses to work right (it just removed the colons instead 
of replacing them with nulls), however preg_replace and str_replace 
worked fine.
$str_new = preg_replace("/:/", chr(0), $str);
or
$str_new = str_replace(":", chr(0), $str);