Abhishek
Abhishek

Reputation: 316

How to find decimal of variables

I have one problem in my project.

$value="Rs.1,195";
echo getfloat($value);

I need out is only

1195

Upvotes: 0

Views: 62

Answers (3)

Dharmendra Singh
Dharmendra Singh

Reputation: 1226

 $string = "Rs.1,195";
 print preg_replace("/[^0-9]/","",$string);

Output = 1195

Upvotes: 3

harsh kumar
harsh kumar

Reputation: 165

$value="Rs.1,195";
$int = filter_var($value, FILTER_SANITIZE_NUMBER_INT);

Upvotes: 0

Bernhard
Bernhard

Reputation: 1870

Maybe you are looking for floatval()

Upvotes: 0

Related Questions