Removing Byte Order Mark (BOM) from the given string.
Posted by admin on Jul 3, 2006 in Blog, Code, PHP | 0 comments
Since PHP does not recognize and ignore BOM in the loaded files, I wrote the following script to find and remove the BOM from the loaded string.
function removeBOM($str=''){
if(<a href="http://www.php.net/strpos">strpos</a>($str, "»")==1)$str=<a href="http://www.php.net/substr">substr</a>($str, 3);
return $str;
}
/*
//Usage:-
$text = removeBOM(file_get_contents("myData.xml",true));
*/
if(<a href="http://www.php.net/strpos">strpos</a>($str, "»")==1)$str=<a href="http://www.php.net/substr">substr</a>($str, 3);
return $str;
}
/*
//Usage:-
$text = removeBOM(file_get_contents("myData.xml",true));
*/
Recent Posts
Recent Comments
Archives
- September 2011
- August 2011
- January 2009
- July 2008
- June 2008
- January 2008
- July 2007
- January 2007
- December 2006
- November 2006
- July 2006
- June 2006
- August 2005
- July 2005
- June 2005
- March 2005
- February 2005
- January 2005
- December 2004
- July 2004
- June 2004
- May 2004
- April 2004
- February 2004
- January 2004
- September 2003
- July 2003
- June 2003
- May 2003
- April 2003
- March 2003
- February 2003
- January 2003
- December 2002
- November 2002
- October 2002
- September 2002