生成用逗号分隔的数字

问题描述:

我想弄清楚如何用变量($ total_days_month)中定义的最大限制以逗号分隔用逗号分隔的x个数字。生成用逗号分隔的数字

<?php 
$total_days_month = date('t'); // get total days of this month 

// generate numbers separated with comma from 1 until $total_days_month 

?> 
+0

你可以试着用'for' – zerkms 2014-10-04 23:55:37

echo implode(',', range(1, $total_days_month)); 
+0

谢谢您的回答! – Roberto 2014-10-04 23:57:41