Recherche sur les Noms des fonctions php/mysql
key()
Définition
Retourne une clé d'un tableau associatif - (PHP 4, PHP 5)Description
key() retourne la clé courante dans le tableau array .
Liste de paramètres
- array
-
Le tableau.
Valeurs de retour
Retourne l'index.
Exemples
Exemple #1 Exemple avec key()
<?php
$array = array(
'fruit1' => 'apple',
'fruit2' => 'orange',
'fruit3' => 'grape',
'fruit4' => 'apple',
'fruit5' => 'apple');
// Cette boucle affiche toutes les clés
// dont la valeur vaut "apple"
while ($fruit_name = current($array)) {
if ($fruit_name == 'apple') {
echo key($array).'<br />';
}
next($array);
}
?>
L'exemple ci-dessus va afficher :
fruit1<br /> fruit4<br /> fruit5<br />
Bouts de code utilisant la fonction key()
<?php /* ... */
`nom` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/* ... */ ?>
<?php /* ... */
dernier int(11) NOT NULL default '0',
PRIMARY KEY (ip)
) TYPE=MyISAM;
/* ... */ ?>
<?php /* ... */
if ($this -> options['ERROR_DISPLAY'] === true) {
echo 'ERREUR! : ', $this -> errorLog[key ($this -> errorLog)],
'<br />';
/* ... */ ?>
<?php /* ... */
if ($this -> options['ERROR_DISPLAY'] === true) {
echo 'ERREUR! : ', $this -> errorLog[key ($this -> errorLog)],
'<br />';
/* ... */ ?>
<?php /* ... */
`pseudo` varchar(32) NOT NULL default '',
PRIMARY key (`ip`)
) TYPE=MyISAM;
/* ... */ ?>
Connexion
Les fonctions
Références
- array_change_key_case...
- array_chunk
- array_combine
- array_count_values
- array_diff_assoc
- array_diff_key
- array_diff_uassoc
- array_diff_ukey
- array_diff
- array_fill_keys
- array_fill
- array_filter
- array_flip
- array_intersect_assoc...
- array_intersect_key...
- array_intersect_uassoc...
- array_intersect_ukey...
- array_intersect
- array_key_exists
- array_keys
- array_map
- array_merge_recursive...
- array_merge
- array_multisort
- array_pad
- array_pop
- array_product
- array_push
- array_rand
- array_reduce
- array_reverse
- array_search
- array_shift
- array_slice
- array_splice
- array_sum
- array_udiff_assoc
- array_udiff_uassoc
- array_udiff
- array_uintersect_assoc...
- array_uintersect_uassoc...
- array_uintersect
- array_unique
- array_unshift
- array_values
- array_walk_recursive...
- array_walk
- array
- arsort
- asort
- compact
- count
- current
- each
- end
- extract
- in_array
- key
- krsort
- ksort
- list
- natcasesort
- natsort
- next
- pos
- prev
- range
- reset
- rsort
- shuffle
- sizeof
- sort
- uasort
- uksort
- usort





