Gen. partnerAlgotech

End()

None

|
August 22, 2019
  • Support PHP 4, PHP 5
  • Short description: sets the internal pointer of an array to its last element.
  • Requirements.

Description

The end() function sets an internal array pointer to the last element and returns its value.

Similar functions

  • current()
  • each()
  • prev()
  • reset()
  • next()

Example

echo end([
'apple',
'banana',
'cranberry',
]); // prints cranberry
$a = [];
$a[1] = 1;
$a[0] = 0;
echo end($a); // prints 0

Parameters

# Type Description
1 array The name of the array to work with.

Return values

Returns the value of the last element or false for an empty array.

Differences from earlier versions

None

Loading comments...

Stay in the loop

Subscribe to our newsletter and get the latest cybersecurity news delivered straight to your inbox.

Your data is safe. You can unsubscribe from the newsletter at any time.