1
我試過substr()但不能讓它工作。我只需要$ leadsmissed,$ panswerrate和$ pcloserate四捨五入到最接近的整數並顯示它。我還需要$ prevenue來顯示小數點後的兩位數字:xxx.xx我如何讓php在我的結果中返回指定數量的字符?
我錯過了它的語法嗎?我對這一切都很陌生。任何幫助,將不勝感激。謝謝!
<?php
$branches = $_POST['branches'];
$closerate = $_POST['closerate'];
$ticketsize = $_POST['ticketsize'];
$leadsperhour = .87;
$revenue = ($branches * $leadsperhour) * $closerate * $ticketsize;
$leadsmissed = $branches * $leadsperhour;
$panswerrate = .92 * $leadsmissed;
$pcloserate = $closerate * $leadsmissed;
$prevenue = $pcloserate * $ticketsize;
$result['string1'] = "Your company, on average, missed " . $leadsmissed . " leads in the past hour. ";
$result['string2'] = "With Pronexis, you would have talked to " . $panswerrate . " of those leads, closed " . $pcloserate . " of them, and received $" . $prevenue . " more revenue!";
echo json_encode($result);
?>
Http://Php.net/number_format –
Http://Php.net/round –