简体   繁体   中英

Need help pulling just one value from a multi-dimensional associative array

Sorry if this is a pretty dumb question, but I'm a PHP novice. I'm storing the results of a query in one element of an associative array ($result["data"]). The data looks something like this:

id     f1     f2     f3
143    1      21     33
143    312    31     4433
143    22     312    412

The id field is guaranteed to store the same value for all elements of the array. I want to store that value (143 in the above sample table) in a variable. I've tried things along the lines of $result["data"]["id"][0], but nothing I try seems to work. I know there's probably a really simple way to do this. What is it?

试试:

$id = $result['data'][0]['id'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM