SetQuery($s"/> SetQuery($s">
Home > Backend Development > PHP Tutorial > 关于循环数组合并的有关问题

关于循环数组合并的有关问题

WBOY
Release: 2016-06-13 13:38:40
Original
834 people have browsed it

关于循环数组合并的问题
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); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template