intval
Get the integer value of the variable
intval()
function returns the integer value of the variable.
Return integer values of different variables:
<?php $a = 32 ; echo intval ( $a ) . "<br>" ; $b = 3.2 ; echo intval ( $b ) . "<br>" ; $c = "32.5" ; echo intval ( $c ) . "<br>" ; $d = array ( ) ; echo intval ( $d ) . "<br>" ; $e = array ( "red" , "green" , "blue" ) ; echo intval ( $e ) . "<br>" ; ?>
Try it yourself
intval ( variable , base ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |
base |
Optional. Specifies the cardinality used for the conversion. Valid only if the variable is a string. The default cardinality is 10. |