Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

reset()

Rewind the internal array pointer and return the first value in its current order.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

reset(array|object &$array): mixed

Rewind the internal array pointer and return the first value in its current order. False can denote either an empty array or a stored false at the first key. Object arguments are deprecated since PHP 8.1.

Signature

reset(array|object &$array): mixed

Example output

[[false,8],[false,null]]

Examples

<?php
$items = [8=>false,4=>"last"]; end($items); $empty = [];
echo json_encode([[reset($items),key($items)],[reset($empty),key($empty)]]);

Result

[[false,8],[false,null]]

Sources