How to convert string to int, or other variable to integer
To convert string to int in PHP you can use casting or intval() function. See example:
$intVariable = intval( $unknownVariable ); // or: $intVariable = (int)$unknownVariable;
You can cast with this function every php variable, like double. Remember that php can throw a error or warning, especially if variable is not set
Comments
Post a Comment