我有一个对象数组
([date]=>2012-01-09, [count]=>5),
([date]=>2012-01-11, [count]=>7),
([date]=>2012-01-12, [count]=>5)
将数组转换为数组对象或数组
的最佳方法是什么?([date]=>2012-01-08, [count]=>0),
([date]=>2012-01-09, [count]=>5),
([date]=>2012-01-10, [count]=>0),
([date]=>2012-01-11, [count]=>7),
([date]=>2012-01-12, [count]=>5),
([date]=>2012-01-13, [count]=>0),
([date]=>2012-01-14, [count]=>0)
假设给予启动日期2012-01-08并结束2012-01-14
答案 0 :(得分:1)
(string) $currentDate
将其转换为PHP代码:)
答案 1 :(得分:0)
我不会为你编写代码,但我会为你提供算法
$compArray = new array();
loop from startdate to enddate as date
{
if (in_array(date, yourarray))
copy the entry from yourarray to compArray
else
enter date into compArray with a count of 0
}