У меня есть json encode
в базе данных, и я хочу только значения echo name_r
в foreach
, как это?
[{ "name_r": "saeed", "units": ["salam", "11", "11", "khobe", "22", "22", "salam"], "price_change": ["33", "33", "33", "44", "44", "44"] }, { "name_r": "salavat", "units": ["55", "55", "khobe", "66", "66"], "price_change": ["77", "77", "77", "88", "88", "88", "99", "99", "99"] }]
это мой php, который имеет ошибку ( Message: Undefined index: name_r - Line Number: 179
):
$query = $this->db->query("SELECT * FROM table ORDER BY id desc"); $data = array(); foreach ($query->result() as $row) { $data[] = json_decode($row->residence,true); echo $data["name_r"].'<br>'; //Line Number: 179 }