published on in HowTo
tags: php

How to extend the ArrayObject and create a custom array

To my friend with lots of love

class MyArray extends ArrayObject {
  public function __construct($array = array()){
    parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);

  public function get_property_string($sep = ':') {
    return implode($sep, $this->getArrayCopy());

  public function __ToString() {
    return 'Array';

  /* some custom method */

$rights = new MyArray;


And the output will be:


Read more: