[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

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)
  • 2
1 Solution
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.
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


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now