我需要创建一个带有 foreach 循环和 while 循环的多维数组。
第一个数组包含以下内容:
Array
(
[0] => 13-10-14
[1] => 13-10-15
[2] => 13-10-16
[3] => 13-10-17
[4] => 13-10-18
[5] => 13-10-19
)
我需要让它看起来像这样:
Array
(
[0] => Array
(
[date] => 13-10-14
[id] => Array
(
[0] => 012643
[1] => 012667
[2] => 013362
[3] => 016169
[4] => 016839
[5] => 035288
[6] => 035369
[7] => 037664
[8] => 038979
[9] => 039014
[10] => 039036
[11] => 039505
)
)
)
第一个数组我做一个 foreach 循环,第二个我需要做 while,因为它是一个 sql 查询。
这是代码:
foreach ($rs as $results) {
$rowT = $db->query("SELECT id FROM users WHERE LIMIT 10");
while ($rsT = $db->fetch_assoc($rowT)) {
$results['id'][] = $rsT;
}
$l_array[] = $results;
}## Heading ##
print_r($l_array);
正在返回错误:
Fatal error: Can not use string offset to an array