Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function reset()


previous

Advertisements

Syntax

reset ( $array );

Definition and Usage

The reset() function rewinds array's internal pointer to the first element and returns the value of the first array element, or FALSE if the array is empty.

Paramters

ParameterDescription
arrayRequired. Specifies an array

Return Value

Returns the first element in an array.

Example

Try out following example:

<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); 
print "$mode <br />";
$mode = next($transport);  
print "$mode <br />";
$mode = current($transport)
print "$mode <br />";; 
$mode = prev($transport);  
print "$mode <br />";
$mode = end($transport);   
print "$mode <br />";
$mode = reset($transport);   
print "$mode <br />";
$mode = current($transport); 
print "$mode <br />";
?> 

This will produce following result:

foot
bike
bike
foot
plane
foot
foot 

previous Printer Friendly

Advertisements


  

Advertisements