How to output the value of a specific key name in a two-dimensional array $ urlquotes. money.163.comhsservicemarketradar _ ajax. php? Page0 & amp; querySTYPE % 3 AEQA & amp; typesJHJJFL & amp; count28 & amp; typequery; & nbsp; match the number of pages & How does nbs output the value of a specific key name in a two-dimensional array
$ Url = 'http: // quotes.money.163.com/hs/service/marketradar_ajax.php? Page = 0 & query = STYPE % 3 AEQA & types = JHJJFL & count = 28 & type = query ';
// Number of matched page numbers
$ File = json_decode (file_get_contents ($ url), true );
$ Out = $ file ['list'];
$ PageCount = (int) $ file ['pagecount'];
// Obtain the stock code on each page and put the corresponding array
For ($ q = 1; $ q <$ pageCount; $ q ++ ){
$ Url = 'http: // quotes.money.163.com/hs/service/marketradar_ajax.php? Page = '. $ q.' & query = STYPE % 3 AEQA & types = JHJJFL & count = 28 & type = query ';
$ File = json_decode (file_get_contents ($ url), true );
Foreach ($ file ['list'] as $ v) $ out [] = $ v;
}
// Var_export ($ out );
How can I output the stock code of all the keys in the $ out array named 'symbol' and put it into a new one-dimensional array?
------ Solution --------------------
PHP code
$ SYMBOLList = array (); // container for ($ q = 1; $ q <$ pageCount; $ q ++) {$ url = 'http: // quotes.money.163.com/hs/service/marketradar_ajax.php? Page = '. $ q. '& query = STYPE % 3 AEQA & types = JHJJFL & count = 28 & type = query'; $ file = json_decode (file_get_contents ($ url), true ); foreach ($ file ['list'] as $ v) {$ out [] = $ v; echo $ v ['symbol']; // you can directly output $ SYMBOLList [] = $ v ['symbol']; // save it to the array and use it }}
------ Solution --------------------
Function get_symbol ($ ar ){
Return $ ar ['symbol'];
}
$ Symbol = array_map ('Get _ symbol', $ out );