2009-02-26 14 views

Répondre

29

rapide Cheatsheet Si vous n'êtes pas familier avec le jargon, voici une traduction rapide des termes de remplacement, qui peut être plus facile à retenir:

* array_unshift() - (aka Prepend ;; InsertBefore ;; InsertAtBegin)  
* array_shift() - (aka UnPrepend ;; RemoveBefore ;; RemoveFromBegin) 

* array_push()  - (aka Append ;; InsertAfter ;; InsertAtEnd)  
* array_pop()  - (aka UnAppend ;; RemoveAfter ;; RemoveFromEnd) 
+0

grand un effet :) –

0

Pour moi array_slice() fonctionne très bien, Dis:

$arr = array(1,2,3,4,5,6); 
//array_slice($array,offset); where $array is the array to be sliced, and offset is the number of array elements to be sliced 
$arr2 = array_slice($arr,3);//or 
$arr2 = array_slice($arr,-3);//or 
$arr2 = array_slice($arr,-3,3);//return 4,5 and 6 in a new array 
$arr2 = array_slice($arr,0,4);//returns 1,2,3 and 4 in a new array 
+0

pourquoi ne pas j ust array_shift() c'est tellement plus efficace? –