Home > AI > Language > PHP >

current

Example :


<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
echo $mode;
    
$mode = next($transport);    // $mode = 'bike';
    
$mode = current($transport); // $mode = 'bike';
    
$mode = prev($transport);    // $mode = 'foot';
$mode = end($transport);     // $mode = 'plane';
$mode = current($transport); // $mode = 'plane';

$arr = array();
var_dump(current($arr)); // bool(false)

$arr = array(array());
var_dump(current($arr)); // array(0) { }
?>

Leave a Reply