ACF: replace comma with another sign

I am using ACF.

I am using this function to display numbers in number fields in this way 1,000.00

// Return ACF Number Fields Formatted with Commas on the Frontend
add_filter('acf/format_value/type=number', 'acf_number_comma_decimal', 20, 3);

// Without Decimal
function acf_number_comma($value, $post_id, $field) {
$value = number_format(floatval($value));
return $value;
}
// With Decimal
function acf_number_comma_decimal($value, $post_id, $field) {
$value = number_format(floatval($value), 2);
return $value;
}

I would like to replace the ” , ” with this ” ‘ ” so the value will be displayed in this way: 1’000.00.

How can i achieve that?

Topic advanced-custom-fields Wordpress

Category Web


Modify the following line in your function:

$value = number_format(floatval($value), 2);

To include another two arguments from the number_format() function - namely the decimal separator (set to a dot) and the thousands separator (set to an apostrophe)

$value = number_format(floatval($value), 2, ".", "'");

So in total this line says: format the number (after floating it to an integer) to two decimal places using a dot to separate decimals and an apostrophe to separate the thousands.

Online demo: https://shorturl.at/twFWX

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.