pos() function in PHP



The pos() function is the alias of current() function in PHP. It returns the current element of the array.

Syntax

pos(arr)

Parameters

  • arr − The specified array. Required.

Return

The pos() function returns the value of the current element in an array.

Example

The following is an example −

 Live Demo

<?php
$arr = array("one", "two");
echo pos($arr);
?>

Output

The following is the output −

one

Example

Let us see another example −

 Live Demo

<?php
$a = array('one', 'two', 'three');
echo current($a)."
"; echo next($a)."
"; echo pos($a)."
"; ?>

Output

The following is the output −

one
two
two
Samual Sam
Samual Sam

Learning faster. Every day.


Advertisements