intval

int intval(mixed value, [int base]) 
value Scalar value to convert to an integer
base Specified base for the integer

Converts a value to an integer.

Returns:

Integer of the specified base (10 if no base is specified)

Description:

intval() attempts to convert a single scalar value to an integer. Integers are whole numbers (such as 1, -2002, 34, 0, and so on).

If a base argument is provided and the value argument is a string, the value is considered to be of the base specified. See the notes and examples for more details.

The function can convert any normal numeric value, as well as numbers that are represented in scientific notation (such as 1.101e45), as a string (such as "1 cup of flour" or "10,000 keys for a single lock"), in octal ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.