How To Access Values In Associative Array Using PHP

前端 未结 3 1507
予麋鹿
予麋鹿 2021-01-25 10:02

I have an array which is the result of a select query using Amazon SimpleDb.

Here is sample data when I print_r($result);

Array ( [0] => Array ( [N         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-25 11:02

    The following will run trough the last part of your array by reference. Therefore edits that you make are reflected in the $result array.

    foreach ($result[0]['Attributes'] as &$item) {
        if ($item['Name'] == 'test_id') // do something
    }
    

提交回复
热议问题