2013-05-07 301 views
0

我有一個php腳本,它使用Youtube API來回應Youtube視頻的查看次數。不過,我希望在數千甚至更多的觀看次數中添加逗號。以四位或更多位數的數字添加逗號

我的代碼如下:

$JSON = file_get_contents('https://gdata.youtube.com/feeds/api/videos/XQu8TTBmGhA?v=2&alt=json'); 
$JSON_Data = json_decode($JSON); 
$views = $JSON_Data->{'entry'}->{'yt$statistics'}->{'viewCount'}; 
echo $views; 

任何幫助,將不勝感激!

+1

你想[number_format()](http://us3.php.net/manual/en/function.number-format.php) – cpilko 2013-05-07 14:25:30

回答

0

使用此

echo number_format($views, 2, '.', ','); 
相關問題