What is the best way to copy/delete an array in php

whats the best way to copy the first num of element in an array in php?
is there a function that do it? (can also cut the other side instead)
Nura111Asked:
Who is Participating?
 
Ray PaseurCommented:
array_pop() will take the last element off an array.
array_slice() will take the first element
unset() will delete an array.

These are all documented on the PHP.net web site.
0
 
Ray PaseurCommented:
Some of the array functions act as if the &array notation is used, so it is wise to read the descriptions carefully.  They are all very old PHP functions and date from the times when we got the needle-haystack confusion of function arguments.  Check the left sidebar of this page for a list of the array functions.  HTH, ~Ray

http://us2.php.net/manual/en/function.array-slice.php
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.