PHP pos() Function

6 Jan 2025 | 1 min read

The PHP 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 was introduced in PHP 4.0.

Syntax

Parameter

ParameterDescriptionIs compulsory
arraySpecifies the array to use.compulsory

Returns

The pos( ) function returns the value of the current element in an array or false on empty elements.

Example 1

Output:

 aajtak 

Example 2

Output:

 aajtak zeenews 

Example 3

Output:

 archery badminton badminton 

Example 4

Output:

 archery badminton badminton archery badminton