Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个变量$day = 5;我想把它变成这样的数组
$day = 5;
$array = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5);
这可能吗?
查看range()功能。
range()
$array = range(0,$day);
旧的,基于 1 的解决方案: