Function: string_to_number()

function string_to_number(string $str, string $dec_point = ".", string $thousand_sep = ","): float|string|null;

Converts the string to number due to the specified settings.

Parameters

Name Pass type Value type Default value Description
$str by value string

The string to be converted.

$dec_point by value string "."

The decimal separator.

$thousand_sep by value string ","

The thousand separator.

Returns

float|string|null

If the string is a vialid number, its numeric value is returned.

Throws

\Exception

It might throw the exception if the string is not a number

Authors

Oleg Schildt

Package

Source code