$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<$pageCount;$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<$pageCount;$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; echo $v['SYMBOL']; // 可以直接输出 $SYMBOLList[] = $v['SYMBOL'];// 存入数组以后用 }}
------解决方案--------------------
function get_symbol($ar) {
return $ar['SYMBOL'];
}
$symbol = array_map('get_symbol', $out);