关于循环数组合并的有关问题
程序员文章站
2024-01-25 09:49:58
...
关于循环数组合并的问题
foreach ($keyword as $val){
$sql="Select title from XXXX title like '%$val%' limit 10 ";
$list = array();
$dsql->SetQuery($sql);
$dsql->Execute();
while ($row = $dsql->GetArray()) {
$list[] = $row;
}
}
结果是这样的。 请问怎么合并 并去除重复。。
Array
(
[0] => Array
(
[title] => 1111111111
)
[1] => Array
(
[title] => 22222222222
)
[2] => Array
(
[title] =>333333333333
)
)
Array
(
[0] => Array
(
[title] => 1111111111
)
)
------解决方案--------------------
foreach ($keyword as $val){
$sql="Select title from XXXX title like '%$val%' limit 10 ";
$list = array();
$dsql->SetQuery($sql);
$dsql->Execute();
while ($row = $dsql->GetArray()) {
$list[] = $row;
}
}
结果是这样的。 请问怎么合并 并去除重复。。
Array
(
[0] => Array
(
[title] => 1111111111
)
[1] => Array
(
[title] => 22222222222
)
[2] => Array
(
[title] =>333333333333
)
)
Array
(
[0] => Array
(
[title] => 1111111111
)
)
------解决方案--------------------
- PHP code
$list = array();foreach ($keyword as $val){ $sql="Select title from XXXX title like '%$val%' limit 10 "; $dsql->SetQuery($sql); $dsql->Execute(); $array = array(); while ($row = $dsql->GetArray()) { array_push($array,$row); } $list[] = $array;}print_r($list);相关文章
相关视频