Created
October 14, 2022 08:41
-
-
Save Oscar-Abad-Folgueira/6df92680866692b5765268588a0ffb58 to your computer and use it in GitHub Desktop.
PHP Snippet: Obtener sólo las claves de un array asociativo en otro array.
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 | |
/** | |
* @snippet PHP Snippet: Obtener sólo las claves de un array asociativo en otro array. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com | |
*/ | |
$array = array("1" => "Uno", "2" => "Dos", "3" => "Tres", "4" => "Cuatro"); | |
print_r(array_keys($array)); | |
// Esto devuelve: | |
Array | |
( | |
[0] => 1 | |
[1] => 2 | |
[3] => 3 | |
[4] => 4 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment