Search Results

  1. Return Values ¶ The key () function simply returns the key of the array element that's currently being pointed to by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list or the array is empty, key () returns null.

  2. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

    • Description
    • Syntax
    • More Examples

    The key()function fetch the key or index of the current element in an array. The following table summarizes the technical details of this function.

    The basic syntax of the key()function is given with: The following example shows the key()function in action.

    Here're some more examples showing how key()function actually works: You can also use this function with indexed array to fetch index of current element. The key()function is commonly used along with the following functions: 1. current()– Returns the value of the current element in an array. 2. next()– Moves the internal pointer of an array to the ...

    • PHP 4+
  3. Jun 20, 2023 · The key () function is an inbuilt function in PHP which is used to return the index of the element of a given array to which the internal pointer is currently pointing.

  4. PHP key function tutorial shows how to get the key of the current array element in PHP. Learn key () with practical examples.

  5. The key() function returns the element key from the current internal pointer position. This function returns FALSE on error= otherwise key. Try out following example − This will produce the following result −

  6. People also ask

  7. La fonction key retourne l’indice ou la clé de la position courante. Utilisation de la fonction key () La signature de la fonction key est la suivante : key ( $array ); /* Déclaration du tableau */ $array = array ( 'langage' => 'php', 'cours' => 'fonction', 'nom' => 'key' ); echo key ($array); /* affiche : langage */ next ($array);