arrays - How to get specific keys from a json file with php -
so have json file
[ { "var1": "6", "var2": "13", "var3": "17" }, { "var1": "9", "var2": "11", "var3": "6" } ]
how can values of var2
13
, 11
?
use json_decode()
$json = '[{ "var1": "6", "var2": "13", "var3": "17"},{ "var1": "9", "var2": "11", "var3": "6"}];' $array = json_decode ($json, true); $values = []; foreach ($array $ar) { $values[] = $ar['var2']; } var_dump($values);
Comments
Post a Comment