Thursday, July 31, 2008

PHP - Trim function

function ewTrim($str) {
$temp = trim($str);
if (strtolower($str) == "null") return "";
if (substr($temp, 0, 1) == "`" && substr($temp, -1, 1) == "`") {
$temp = substr($temp, 1, -1);
} elseif (substr($temp, 0, 1) == "'" && substr($temp, -1, 1) == "'") {
$temp = substr($temp, 1, -1);
$temp = (get_magic_quotes_gpc()) ? stripslashes($temp) : $temp;
}
return $temp;
}


Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.

No comments: