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 关注
- 75 浏览
添加回答
举报