PHP String to Float

前端 未结 8 1282
别跟我提以往
别跟我提以往 2020-11-28 05:37

I am not familiar with PHP at all and had a quick question.

I have 2 variables pricePerUnit and InvoicedUnits. Here\'s the code that is set

8条回答
  •  孤独总比滥情好
    2020-11-28 06:00

    You want the non-locale-aware floatval function:

    float floatval ( mixed $var ) - Gets the float value of a string.

    Example:

    $string = '122.34343The';
    $float  = floatval($string);
    echo $float; // 122.34343
    

提交回复
热议问题