Php obține primul element de matrice

Exemple de cod

4
0

php obține primul element de matrice

$colors = array(2=>"blue",3 =>"green",1=>"red");
$firstValue = reset($colors); //blue
$firstKey = key($colors); //2
2
0

obține prima cheie de php matrice

$firstKey = array_key_first($array);
1
0

primul element în array php

$firstItem = array_shift($array);
1
0

obține primul element de php matrice

array_values($array)[0];
1
0

php obține primul element de matrice

<?php
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_shift($stack); //Remove "orange" from array and return it
print_r($stack);
/** OUTPUT:
Array
(
    [0] => banana
    [1] => apple
    [2] => raspberry
)
*/
?>
0
0

php array obține primele elemente x

$sliced_array = array_slice($array, 0, 5)

În alte limbi

Această pagină este în alte limbi

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................