PHP funkce array_slice()

11. 9. 2019

Dostupnost ve verzích: PHP 4.0

Extract a slice of the array

Parametry

Parametr Datový typ Výchozí hodnota Poznámka
$array array není The input array.
$offset int není If offset is non-negative, the sequence will start at that offset in the array. If offset is negative, the sequence will start that far from the end of the array.
$length int null, If length is given and is positive, then the sequence will have that many elements in it. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array.
$preserve_keys bool false Note that array_slice will reorder and reset the array indices by default. You can change this behaviour by setting preserve_keys to true.

array

the slice.

Další zdroje

Oficiální dokumentace funkce array-slice

Jan Barášek
Jan BarášekVíce o autorovi

Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.

Rád vám pomůžu:

AI konzultace & implementace

Pomohu vám zavést AI do vašeho projektu – od analýzy a návrhu řešení až po nasazení do produkce. Ušetřete čas, zjednodušte procesy a získejte konkurenční výhodu.

Domluvit konzultaci
Konzultant: Jan Barášek
Potřebujete poradit s PHP?

Nabízím trénink vývojářů, konzultace, školení a analýzu návrhových vzorů. Osobně v Praze nebo online.

Napište mi
V jiných jazycích

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.