-1
我想要查詢格式正確。如何正確使用number_format?
我需要所有結果在前面都有'$
',任何小於300的結果都會在末尾加上'/mo.*
'。它沒有做我想做的事。有任何建議嗎?提前致謝!
public function get_under300_specials() {
$this->db->select(' vehicle_specials.type, vehicle_specials.stock_number, inventory.year, inventory.make, inventory.model, inventory.trim, vehicle_specials.price, vehicle_specials.msrp, vehicle_specials.was, vehicle_specials.description, inventory.photos')->from('vehicle_specials')->join('inventory', 'inventory.stock_number = vehicle_specials.stock_number');
$this->db->where("vehicle_specials.price < 300");
$this->db->where('status','active');
//return $this->db->get();
$results = $this;
foreach ($results as $key => $result) { // Format number
$results[$key]['price'] = '$' . number_format($result['price']) . (($result['price'] < 300) ? '/mo.*' : '');
}
return $results->db->get();
}
什麼,祈禱告訴你,你會喜歡它做的。或者我們都會猜測? –
預期格式是什麼? –
這裏看起來很好。你檢查了什麼值? –