php - Why it's not possible to use Array Functions on Objects implementing the ArrayAccess interface -


i have obj class php documentation:

class obj implements arrayaccess {     private $container = array();      public function __construct() {         $this->container = array(             "one"   => 1,             "two"   => 2,             "three" => 3,         );     }      public function offsetset($offset, $value) {         if (is_null($offset)) {             $this->container[] = $value;         } else {             $this->container[$offset] = $value;         }     }      public function offsetexists($offset) {         return isset($this->container[$offset]);     }      public function offsetunset($offset) {         unset($this->container[$offset]);     }      public function offsetget($offset) {         return isset($this->container[$offset]) ? $this->container[$offset] : null;     } } 

now, when try use in_array function like

$obj = new obj; echo in_array('1', $obj); 

i an

warning: in_array() expects parameter 2 array, object given 

shouldn't object implements arrayaccess act actual array?


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -