I'm developing a real estate site and I'll use the REST
feature. 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 do you extract one-by-one data from real estate arrays as indexes?
What I do know is that $result
is saving everything inside it and putting print_r
it releases the properties. How to break this information down into indexes, something like:
echo $result['fields']['Codigo'];
The print_r($result)
prints this:
Array
(
[62] => Array
(
[Codigo] => 62
[Cidade] => Porto Alegre
[Bairro] => Espirito Santo
[ValorVenda] => 105000
)
[69] => Array
(
[Codigo] => 69
[Cidade] => Porto Alegre
[Bairro] => Central
[ValorVenda] => 90000
) ...