which one should be used to manipulating data, Array or Array Object? Like search,sort and other array manipulations.
Most of the time an array is all that's needed. ArrayObject is most useful when extended for functionality in particular uses.
The basic type is array
. This is a map of keys and values that can be written to, read from and accessed in a loop.
The ArrayObject
is a class that you can extend to create objects that behave as if they were arrays. It implements methods like count
and sort
that enable you to treat an object like you would treat an array. It's part of the SPL (Standard PHP Library).
Typically you'd use array
. You'll know when you need ArrayObject
.
you use array
for simple (and standard) arrays
ArrayObject
is a class, which can be used to enhance your own Classes to be used as arrays (say some Collection Class of yours)
arrayObject is mostly useful when serialization is needed.
Also you can create your own collection class by extending arrayObject. Then you can serialize your class object to transfer data.
for simple and usual operation array is more prefferable than arrayObject.