when I want to convert a numeric string variable into integer in php, the return value is zero. I used all ways to convert it! such as:(int), (integer), intval(), settype(), eval(), etc. all of them return zero!
var_dump($myVariable) prints the following:
string(4) "۲۹"
Other common error is trying to cast a string variable that contains numbers but starts with zero, i.e.:
string(5) " 358"
To solve this, I used a filter_var sanitizing number INT doing this:
$myVariable = filter_var($myVariable, FILTER_SANITIZE_NUMBER_INT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With