Is there a more efficient way to convert a string input with commas to a double value in PHP?

When converting a string input with commas to a double value in PHP, one efficient way to do this is by removing the commas from the string before converting it to a double. This can be achieved using the str_replace() function to replace all commas with an empty string. Once the commas are removed, the string can then be safely converted to a double using the (double) or floatval() function.

$input = "1,234.56";
$cleaned_input = str_replace(',', '', $input);
$double_value = (double) $cleaned_input;

echo $double_value; // Output: 1234.56