PHP - Function end()



Syntax

end ( $array );

Definition and Usage

The end() function advances array's internal pointer to the last element, and returns its value.

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array

Return Value

It returns the last 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