我试图继续使用PDO&使用fetchall(PDO :: FETCH_ASSOC)。 现在当我的函数返回2个结果时,实际上只返回了1个。
$ tracksinpl就像一个带有' TrackId'的数组的集合。专栏:
在我的例子中我使用:
Array
(
[0] => Array
(
[TrackId] => 4
)
[1] => Array
(
[TrackId] => 5
)
)
$ tracks就像是一个带有' id'的数组的集合。专栏
在我的例子中我使用:
Array
(
[0] => Array
(
[id] => 1
[title] => a
)
[1] => Array
(
[id] => 2
[title] => abc
)
[2] => Array
(
[id] => 3
[title] => test
)
[3] => Array
(
[id] => 5
[title] => this is title
)
[4] => Array
(
[id] => 6
[title] => title1
)
[5] => Array
(
[id] => 7
[title] => title2
)
)
现在用于处理数据的代码
$count=0
foreach($tracksinpl as $trinpl)
{
foreach($tracks as $track)
{
if($track['id'] == $trinpl['TrackId'])
{
$count= $count +1;
}
}
}
现在当返回count时,它的值是1,应该是2,为什么? 提前谢谢!