Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Oscar-Abad-Folgueira/6df92680866692b5765268588a0ffb58 to your computer and use it in GitHub Desktop.
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.
<?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