Hi, I can’t seem to access this json_decoded array in php:
<?php
$test = '{"information":[{"input":"noecall","output":"onecall","count":1},{"input":"oncall","output":"onecall","count":1},{"input":"onecal","output":"onecall","count":1},{"input":"onecall","output":"onecall","count":1},{"input":"onecaøø","output":"onecall","count":1},{"input":"one.call","output":"onecall","count":1},{"input":"onecal","output":"onecall","count":1},{"input":"onecall","output":"onecall","count":1},{"input":"onecol","output":"onecall","count":1}]} ';
$test = json_decode($test, true);
var_dump($test);
I’ve tried different loop methods , but cant seem to understand how to do what I want, which is:
- loop through array and assign ‘input’ value to $input , ‘output’ value to $output and ‘count’ value to $count
In javascript this would be as following:
for (i = 0; i < test.information.length; i++) {
input = test.information[i].input;
output = test.information[i].output;
count = test.information[i].count;
//then do something with the variables before they are overwritten in the next iteration in the array
}
any help is appreciated
thanks