Jump to: navigation, search

Php current

From w3cyberlearnings

Contents

PHP function current

This function returns the current array element.

Syntax current

  • array: array input
current(array);

NOTE

Alias of this function is pos() function

Example 1

<?php

$array = array(
	 'Semester 1',
	 'Semester 2',
	 'Semester 3',
	 'Semester 4',
	 'Semester 5',
	 'Semester 6',
	 'Semester 7',
	 'Semester 8'
);


// by default, the pointer is on the first element semester 1
echo current($array) . "<br />"; // "semester 1"

// skip two semesters
next($array); // 
next($array); // 

echo current($array) . "<br/>"; // semester 3
// skip three semesters
next($array); //
next($array); //
next($array); //

echo current($array) . "<br />"; // "semester 6"

// current pointer, start again on semester 1
current($array);
echo current($array) . "<br />"; // "semester 1"
?>

Output

Semester 1
Semester 3
Semester 6
Semester 1

Related Links


Navigation
Web
SQL
MISC
References