Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

[Ajuda] Imprimir Array Key->Value

$
0
0
Boa tarde a todos,

Preciso de uma ajuda. Por algum motivo que não estou a conseguir imprimir o conteúdo do array em php.

Com a instrução:
Código (PHP):
echo <pre>;
print_r ($result);
echo </pre>;

Imprimir o seguinte resultado:

Código :
Array
(
[restaurants] => Array
         (
                 [0] => Array
                         (
                                 [name] => The Star
                                 [type] => Array
                                         (
                                                 [0] => restaurant
                                                 [1] => food
                                                 [2] => casino
                                                 [3] => spa
                                                 [4] => lodging
                                                 [5] => point_of_interest
                                                 [6] => establishment
                                         )
                                 [vicinity] => 80 Pyrmont Street, Pyrmont
                         )
                 [1] => Array
                         (
                                 [name] => South Steyne
                                 [type] => Array
                                         (
                                                 [0] => restaurant
                                                 [1] => food
                                                 [2] => point_of_interest
                                                 [3] => establishment
                                         )
                                 [vicinity] => Harbourside Jetty, Darling Drive, Darling Harbour
                         )
                 [2] => Array
                         (
                                 [name] => ibis Sydney Darling Harbour
                                 [type] => Array
                                         (
                                                 [0] => restaurant
                                                 [1] => food
                                                 [2] => lodging
                                                 [3] => point_of_interest
                                                 [4] => establishment
                                         )
                                 [vicinity] => 70 Murray Street, Pyrmont
                         )
                 [3] => Array
                         (
                                 [name] => Blue Fish
                                 [type] => Array
                                         (
                                                 [0] => restaurant
                                                 [1] => food
                                                 [2] => point_of_interest
                                                 [3] => establishment
                                         )
                                 [vicinity] => Harbourside Shopping Centre, Darling Drive, Darling Harbour
                         )
                 [4] => Array
                         (
                                 [name] => Flying Fish Restaurant & Bar
                                 [type] => Array
                                         (
                                                 [0] => bar
                                                 [1] => restaurant
                                                 [2] => food
                                                 [3] => point_of_interest
                                                 [4] => establishment
                                         )
                                 [vicinity] => Lower Deck, Jones Bay Wharf, 21 Pirrama Road, Pyrmont
                         )
                 [5] => Array
                         (
                                 [name] => John St Square Supermarket
                                 [type] => Array
                                         (
                                                 [0] => food
                                                 [1] => store
                                                 [2] => point_of_interest
                                                 [3] => establishment
                                         )
                                 [vicinity] => 8/45-55 Harris Street, Pyrmont
                         )

O que eu quero, é imprimir essas informações ou seja, para a primeira opção:

Nome: The Star
Tipo: food, casino, spa, lodging, point_of_interest, establishment
Morada: 80 Pyrmont Street, Pyrmont

Estou a usar o seguinte código:
Código (PHP):
foreach ($result as $value){
          echo "Nome: ".$value["name"];
          echo "<br>";
          echo "Tipo: ";
          foreach($value->types as $valuearr){
                echo $valuearr["type"];
                echo "<br>";
          }
          echo "Morada: ".$value["vicinity"];
          echo "<br><br>";
        }

Mas apenas imprime:
Nome:
Tipo:
Morada:

Que estou a fazer mal para não imprimir as informações?

Obrigado.

P.S. sei que o tipo ainda não está a separar por ",".

Viewing all articles
Browse latest Browse all 14700