Skip to content

Instantly share code, notes, and snippets.

@jeffersonchaves
Created January 16, 2025 20:01
Show Gist options
  • Save jeffersonchaves/073d5897cf8e9b690877799bd7c67826 to your computer and use it in GitHub Desktop.
Save jeffersonchaves/073d5897cf8e9b690877799bd7c67826 to your computer and use it in GitHub Desktop.
Pokedex
<?php
$pokeNome = readline("informe o pokémon: ");
$url = "https://pokeapi.co/api/v2/pokemon/$pokeNome";
$arquivo = file_get_contents($url);
$pokemon = json_decode($arquivo, true);
print("nome: " . ucfirst($pokemon['name']) . "\n");
print("peso: " . $pokemon['weight'] / 10 . " kg\n");
print("altura: " . $pokemon['height'] * 10 . " cm\n");
print("tipos: \n");
foreach ($pokemon['types'] as $tipo) {
print " - " . $tipo['type']['name']. "\n";
}
print($pokemon['sprites']['other']['dream_world']['front_default']."\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment