Let me explain my problem, I am supposed to call a web service before the contact form is shown, the return of the web service is:
$items = json_decode('[{"location":[{"building":["Building1"],"name":"Location1"}],"name":"Organization1"},{"location":[{"building":["Building2"],"name":"location2"}],"name":"Organisation2"},{"location":[{"building":["Building3"],"name":"Location3"}],"name":"Organization3"}]');
Here I have extracted only the organisations,locations and building using the following code:
foreach( $items as $each ){
echo $each->location[0]->building[0];
echo $each->location[0]->name;
echo $each->name;
}
I would like to get the values of organisations, buildings and locations in different arrays in this format:
("building1", "building2", "building3")
("organisation1", "organisation2", "organisation3")
("location1", "location2", "location3")