HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

reset

Description

The reset of Array for PHP sets the internal pointer of an array to its first element.

Syntax

reset(
    array|object &$array
): mixed

Parameters

array

The input array.

Return

Returns the value of the first array element, or false if the array is empty.

Examples

1 · reset

<?

$array =
[
    0,
    1,
    2
];

$return = reset($array);

echo $return;
0

2 · empty

<?

$array = [];

$return = reset($array);

var_export($return);
false

3 · order

<?

$array = [];
$array[0] = 0;
$array[1] = 1;
$array[2] = 2;

$return = reset($array);

echo $return;
0

4 · order

<?

$array = [];
$array[2] = 2;
$array[1] = 1;
$array[0] = 0;

$return = reset($array);

echo $return;
2