How to output the value of a specific key name in a two-dimensional array

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.