Home > Backend Development > PHP Tutorial > 怎么输出二维数组中特定键名的值

怎么输出二维数组中特定键名的值

WBOY
Release: 2016-06-13 10:35:38
Original
995 people have browsed it

如何输出二维数组中特定键名的值
$url='http://quotes.money.163.com/hs/service/marketradar_ajax.php?page=0&query=STYPE%3AEQA&types=JHJJFL&count=28&type=query';
  //匹配页码数
  $file=json_decode(file_get_contents($url),true);
  $out=$file['list'];
  $pageCount=(int)$file['pagecount'];
  //获取每一页的股票代码并放入相应的数组
  for($q=1;$q   $url='http://quotes.money.163.com/hs/service/marketradar_ajax.php?page='.$q.'&query=STYPE%3AEQA&types=JHJJFL&count=28&type=query';
  $file=json_decode(file_get_contents($url),true);
  foreach($file['list'] as $v) $out[]=$v;
  }
  //var_export($out);

请问如何输出$out数组中所有键名为'SYMBOL'后的股票代码,并将其放入一个新的一维数组中

------解决方案--------------------

PHP code
$SYMBOLList = array();// 容器for($q=1;$q<font color="#e78608">------解决方案--------------------</font><br>function get_symbol($ar) {<br> return $ar['SYMBOL'];<br>}<br><br>$symbol = array_map('get_symbol', $out);<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