PHP - Function current()



Syntax

current ( $array );

Definition and Usage

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

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array

Return Value

It returns the current element in an array.

Example

Try out following example −

";
   
   $mode = next($transport);  
   print "$mode 
"; $mode = current($transport); print "$mode
"; $mode = prev($transport); print "$mode
"; $mode = end($transport); print "$mode
"; $mode = current($transport); print "$mode
"; ?>

This will produce the following result −

foot
bike
bike
foot
plane
plane 
php_function_reference.htm
Advertisements