Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php array current


<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$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) { }
?>

Comment

PREVIOUS NEXT
Code Example
Php :: Codeigniter 3 Pass anything in query string 
Php :: file get content php post 
Php :: laravel casts AsCollection 
Php :: multe data on database laravel 
Php :: how to create cookie in laravel 
Php :: spatie activity log 
Php :: php check if day in month 
Php :: how to add two string in php 
Php :: laravel crud 
Php :: make controller and model laravel 
Php :: how to use uuid in laravel model 
Php :: Get data from array (from an API) in Laravel 
Php :: laravel run schedule only on production 
Php :: get element by index array php 
Php :: drupal 8 entity_view 
Php :: timezones php 
Php :: catch warning php 
Php :: connect php in sql server 
Php :: PHP strtok — Tokenize string 
Php :: check multiple roles with Blade directive @can? 
Php :: multiple ternary operator in php 
Php :: Call to undefined method PsyUtilStr::random() 
Php :: Laravel Nested whenLoaded 
Php :: Trying to access variable outside laravel collection 
Php :: php remove duplicates from string 
Php :: laravel self 
Php :: Edit PHP INI 
Php :: PHP code to read JSON string on server 
Php :: select statement of table in phpmyadmin 
Php :: insert views laravel database 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =