1 回答

TA貢獻2051條經驗 獲得超10個贊
這可以通過PHP str_replace() 函數來實現
您可以從短代碼獲得的結果中刪除逗號并將該值存儲在新變量中。
最后把代碼寫成這樣:
$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 關注
- 109 瀏覽
添加回答
舉報