, когда я отправлю 1,000,000
, отображается как 1
, но если я отправлю 1000000
, отображается как 1,000,000
. Я хочу, чтобы выход был 1,000,000
, независимо от того, как он отправлен. Пожалуйста, помогите!Как отключить преобразование десятичной точки в php
Вот PHP код:
if(!function_exists('get_property_price')){
function get_property_price(){
global $post;
$price_digits = doubleval(get_post_meta($post->ID, 'REAL_HOMES_property_price', true));
if($price_digits){
$currency = get_theme_currency();
$price_post_fix = get_post_meta($post->ID, 'REAL_HOMES_property_price_postfix', true);
$decimals = intval(get_option('theme_decimals'));
$decimal_point = get_option('theme_dec_point');
$thousands_separator = get_option('theme_thousands_sep');
$currency_position = get_option('theme_currency_position');
$formatted_price = number_format($price_digits,$decimals, $decimal_point, $thousands_separator);
if($currency_position == 'after'){
return $formatted_price . $currency. ' ' . $price_post_fix;
}else{
return $currency . $formatted_price . ' ' . $price_post_fix;
}
}else{
return __('NA','framework');
}
}
}
if(!function_exists('property_price')){
function property_price(){
echo get_property_price();
}
}
if(!function_exists('get_custom_price')){
function get_custom_price($amount){
$amount = doubleval($amount);
if($amount){
$currency = get_theme_currency();
$decimals = intval(get_option('theme_decimals'));
$decimal_point = get_option('theme_dec_point');
$thousands_separator = get_option('theme_thousands_sep');
$currency_position = get_option('theme_currency_position');
$formatted_price = number_format($amount,$decimals, $decimal_point, $thousands_separator);
if($currency_position == 'after'){
return $formatted_price . $currency;
}else{
return $currency . $formatted_price;
}
}else{
return __('NA','framework');}}}
Вы сомневаетесь, что это неправильно. PHP не преобразует эти значения в десятичные значения разделенных значений, ваша инфраструктура делает. В вашей теме найдите опции 'theme_thousands_sep' и' theme_dec_point'. – GuyT
Возможный дубликат [Разбор номера, но сохранить отрицательный] (http: // stackoverflow.com/questions/19964723/parse-a-number-but-keep-negatives) – Tigger
GuyT Я попытался отключить их из функции.php bt никаких изменений –