I am trying to get only integer from string for these i am using filter_var in php
Here is my code
$str="Your base price is 456";
echo filter_var($str,FILTER_SANITIZE_NUMBER_INT);
But if the string contains a floating point value filter_var returns integer without the floating point value.
Eg;
$str="Your base price is 45.57";
echo filter_var(currencyConvert($currency,$results[0]->base_price),FILTER_SANITIZE_NUMBER_INT);
this will echo integer as 4557 but i need the value as same as the string.
ie it should be 45.57 but i will get it as 4557
Is any way to get this as correct float value?
FILTER_SANITIZE_NUMBER_FLOAT? Generally, it is not advisable to use INT functions on non-integers, and this is one of many such cases.