1 回答

TA貢獻(xiàn)2051條經(jīng)驗(yàn) 獲得超10個(gè)贊
這可以通過(guò)PHP str_replace() 函數(shù)來(lái)實(shí)現(xiàn)
您可以從短代碼獲得的結(jié)果中刪除逗號(hào)并將該值存儲(chǔ)在新變量中。
最后把代碼寫成這樣:
$first_number = do_shortcode("[gravitywp_count formid='1' number_field='3']");
$second_number = do_shortcode("[gravitywp_count formid='2' number_field='3']");
$first_number_sep = str_replace( ',', '', $first_number );
$second_number_sep = str_replace( ',', '', $second_number );
if( is_numeric( $first_number_sep &&? $second_number_sep) ) {
? ? $first_number = $first_number_sep;
? ? $second_number = $second_number_sep;
}
$sum_total = $first_number_sep + $second_number_sep;
$sum_total = $first_number_sep + $second_number_sep;
$total_formatted = number_format($sum_total, 2, '.', ','); //formats the number back to the comma state
echo 'The two variables added together = ' . $total_formatted;
- 1 回答
- 0 關(guān)注
- 115 瀏覽
添加回答
舉報(bào)