Created
January 16, 2025 20:01
-
-
Save jeffersonchaves/073d5897cf8e9b690877799bd7c67826 to your computer and use it in GitHub Desktop.
Pokedex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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