I have an array returned from an api call. Sometimes it will be just one set and at others many sets. The example is below, taken for page "view source":
[objects] => Array
(
[0] => Array
(
[stock] => 388
[voice_enabled] => 1
[region] => BASEL, SWITZERLAND
[voice_rate] => 0.00800
[prefix] => 61
[sms_rate] => -1
[number_type] => local
[setup_rate] => 0.80000
[rental_rate] => 0.80000
[group_id] => 25728319905588
[sms_enabled] =>
[resource_uri] => /v1/Account/MAMTE4MTHJNJRKODBIMD/AvailableNumberGroup/25728319905588/
)
[1] => Array
(
[stock] => 593
[voice_enabled] => 1
[region] => BELLINZONA, SWITZERLAND
[voice_rate] => 0.00800
[prefix] => 91
[sms_rate] => -1
[number_type] => local
[setup_rate] => 0.80000
[rental_rate] => 0.80000
[group_id] => 25732565267448
[sms_enabled] =>
[resource_uri] => /v1/Account/MAMTE4MTHJNJRKODBIMD/AvailableNumberGroup/25732565267448/
)
There are 10 more such blocks.
This is produced by an api call from the following PHP file:
<?php
include("connect.php");
include("settings.php");
require_once 'myapiprovider.php';
$p = new RestAPI($auth_id, $auth_token);
$params = array( 'country_iso' => 'CH' );
$response = $p->get_number_group($params);
print_r($response);
?>
Instead of print_r($response) I would like to be able to loop through the items and echo just the region and the prefix in a nice list.
How can I do this?
Many thanks in advance for your help.
foreach($response["objects"] as $i=>$v)
{
echo "Region: ".$v["region"];
echo "<br>";
echo "Prefix: ".$v["prefix"];
echo "<hr>";
}