How to detect padding on an integer and treat it as a string?
- by Sirber
I have this function to prepare variable to be used in a SQL query:
function sqlize($mInput)
{
if (!isset($mInput))
$mInput = "null";
elseif (strtolower($mInput) == "null") { }
elseif (is_numeric($mInput)) { }
elseif (is_string($mInput))
{
$mInput = trim($mInput);
$mInput = addslashes($mInput);
$mInput = '"' . $mInput . '"';
}
else
$mInput = "null";
return $mInput;
}
I have a string "0004", which is going in a "varchar field", is cought by is_numeric, and is saved as "4" and not "0004". Is there a way to detect the padding and process it as a string?
Thank you!