pos() function in PHP

PHPProgrammingServer Side Programming

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)."\n";
echo next($a)."\n";
echo pos($a)."\n";
?>

Output

The following is the output −

one
two
two
raja
Published on 15-Oct-2018 10:09:20
Advertisements