PHP pos() Function

PHP pos Function


Definition :

In PHP array functions pos( )  function is used to fetch the value of the current element in an array. The PHP pos( ) function is an alias of current( ) function.

This function is an alias of the current() function.

Every array has an internal pointer to its "current" element, which is initialized to the first element inserted into the array

Tip: This function does not move the arrays internal pointer.

Related methods:

  • current() - returns the value of the current element in an array
  • end() - moves the internal pointer to, and outputs, the last element in the array
  • next() - moves the internal pointer to, and outputs, the next element in the array
  • prev() - moves the internal pointer to, and outputs, the previous element in the array
  • reset() - moves the internal pointer to the first element of the array
  • each() - returns the current element key and value, and moves the internal pointer forward

Syntax

pos(array)

Parameter Values

Parameter Description
array Required. Specifies the array to use

Example : Given below example output the value of current element of an array.

Output : Web