arrayobject

Does PHP's ArrayObject have an in_array equivalent?

PHP has an in_array function for checking if a particular value exists in an native array/collection. I'm looking for an equivalent function/method for ArrayObject, but none of the methods appear to duplicate this functionality. I know I could cast the ArrayObject as an (array) and use it in in_array. I also know I could manually iter...

PHP Array and ArrayObject

which one should be used to manipulating data, Array or Array Object? Like search,sort and other array manipulations. ...

Which PHP interface allows objects' properties to be accessible with array notation?

Which PHP SPL interface allows objects to do this: $object->month = 'january'; echo $object['month']; // january $record['day'] = 'saturday'; echo $record->day; // saturday e.g. such as in libraries like Doctrine (Doctrine_Record) how do I implement this? I've tried using ArrayObject, but they don't behave as I thought they would. ...

Extended PHP ArrayObject Does Not Work Properly

I'm trying to extend the SPL ArrayObject but I've hit a little snag. Using an unmodified ArrayObject, this code works: $a = new ArrayObject(); $a[1][2] = 'abc'; print_r($a); yielding this output: ArrayObject Object ( [storage:ArrayObject:private] => Array ( [1] => Array ( [...

Sorting an array

If I have an array of data, what is the best option for sorting them so they are displayed in ascending alphabetical order based on key 2 of the second array within each ArrayObject? Data ArrayObject::__set_state(array( 'job_category_filter_population' => ArrayObject::__set_state(array( 10225 => ArrayObject::__set_state...

Reset the Internal Pointer Value of a PHP Array (ArrayObject)

Consider a simple PHP ArrayObject with two items. $ao = new ArrayObject(); $ao[] = 'a1'; // [0] => a1 $ao[] = 'a2'; // [1] => a2 Then delete the last item and add a new item. $ao->offsetUnset(1); $ao[] = 'a3'; // [2] => a3 I'd very much like to be able to have 'a3' be [1]. How can I reset the internal pointer value before I add...

Iterating over multi-level ArrayObject() to print out on-screen hierarchical view

Hi, I have a ArrayObject structure that is quite complex to output, it can/and consists of multiple levels of relationship e.g. Parent -> Child -> Children -> Child etc. Structures like this are quite complex to work with when using a foreach, for or while loop. I've looked into SPL Iterators and I think this can be used. I'm a bit unf...