-1
I’m developing a real estate website and I will use the REST
. The code below returns me one by one the properties registered in the server software as can be seen here.
$dados = array(
'fields' =>
array(
'Codigo', 'Cidade', 'Bairro', 'ValorVenda'
),
'paginacao' =>
array(
'pagina' => 1,
'quantidade' => 10
)
);
$key = 'c9fdd79584fb8d369a6a579af1a8f681';
$postFields = json_encode( $dados );
$url = 'http://sandbox-rest.vistahost.com.br/imoveis/listar?key=' . $key;
$url .= '&showtotal=1&pesquisa=' . $postFields;
$ch = curl_init($url);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER , array( 'Accept: application/json' ) );
$result = curl_exec( $ch );
$result = json_decode( $result, true );
echo '<pre>';
print_r( $result );
echo '<pre>';
My question is: in this case, how to extract one by one of the property arrays data in index form?
What I do know is that the $result
is keeping everything inside him and putting a print_r
he releases the real estate. How to dismember this information in the form of indexes, something like:
echo $result['fields']['Codigo'];
The print_r($result)
print this out:
Array
(
[62] => Array
(
[Codigo] => 62
[Cidade] => Porto Alegre
[Bairro] => Espirito Santo
[ValorVenda] => 105000
)
[69] => Array
(
[Codigo] => 69
[Cidade] => Porto Alegre
[Bairro] => Central
[ValorVenda] => 90000
) ...