I have data below in the array that I got from JSON like this
$page = file_get_contents("http://giswebcenter.mwa.co.th/mwa/ashx/Proxy.ashx");
$json_output = json_decode($page);
and then I have data like this when I print_r($json_output)
stdClass Object
(
[success] => 1
[total] => 850
[message] =>
[data] => Array
(
[0] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 03
[BLOCK] => 04
[MATL] => ST
[LENGTH] => 516.492
)
[1] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 03
[BLOCK] => 05
[MATL] => SCP
[LENGTH] => 19.177
)
[2] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 03
[BLOCK] => 05
[MATL] => ST
[LENGTH] => 519.355
)
[3] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 03
[BLOCK] => 06
[MATL] => SCP
[LENGTH] => 59.713
)
[4] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 03
[BLOCK] => 06
[MATL] => ST
[LENGTH] => 476.866
)
[5] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 04
[BLOCK] => 03
[MATL] => SCP
[LENGTH] => 64.875
)
[6] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 04
[BLOCK] => 03
[MATL] => ST
[LENGTH] => 44.888
)
[7] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 04
[BLOCK] => 05
[MATL] => SCP
[LENGTH] => 19.979
)
[8] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 04
[BLOCK] => 05
[MATL] => ST
[LENGTH] => 28.591
)
[9] => stdClass Object
(
[BRANCH] => 01
[ZONE] => 04
[BLOCK] => 07
[MATL] => SCP
[LENGTH] => 38.967
)
)
)
I'd like to filter data in the array as ZONE='03'
and I've tried this code with array_filter() but noting.
function filterZone($obj)
{
return $obj['data']->BRANCH == "01";
}
$BRANCH = array_filter($json_output, 'filterZone');
print_r($BRANCH);
Can anyone help or suggest me to do this?
Thank you.