Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Standard PHP Library (SPL) Functions : ArrayObject::__construct

ArrayObject::__construct

Construct a new array object ()
ArrayObject ArrayObject::__construct ( mixed input )

Example 2310. ArrayObject::__construct() example

<?php
$array
= array('1' => 'one',
             
'2' => 'two',
             
'3' => 'three');

$arrayobject = new ArrayObject($array);

var_dump($arrayobject);
?>

The above example will output:

object(ArrayObject)#1 (3) {
 [1]=>
 string(3) "one"
 [2]=>
 string(3) "two"
 [3]=>
 string(5) "three"
}

Code Examples / Notes » arrayobject_construct

agalkin

Note that the first argument to ArrayObject::__construct, the initial array, is passed by reference. Nevertheless, modification of the array doesn't modify the object, so it may cause unexpected behaviour.
<?php
$array = array('foo' => 'initial');
$obj = new ArrayObject($array);
// array was passed by reference:
$obj['foo'] = 'modified';
var_dump($array); // foo => modified
// but it doesn't work backwards:
$array['foo'] = 'modified_again';
var_dump($obj); // foo => modified
var_dump($array); // foo => modified_again
?>


Change Language


Follow Navioo On Twitter
ArrayIterator::current
ArrayIterator::key
ArrayIterator::next
ArrayIterator::rewind
ArrayIterator::seek
ArrayIterator::valid
ArrayObject::append
ArrayObject::__construct
ArrayObject::count
ArrayObject::getIterator
ArrayObject::offsetExists
ArrayObject::offsetGet
ArrayObject::offsetSet
ArrayObject::offsetUnset
CachingIterator::hasNext
CachingIterator::next
CachingIterator::rewind
CachingIterator::__toString
CachingIterator::valid
CachingRecursiveIterator::getChildren
CachingRecursiveIterator::hasChildren
DirectoryIterator::__construct
DirectoryIterator::current
DirectoryIterator::getATime
DirectoryIterator::getCTime
DirectoryIterator::getFilename
DirectoryIterator::getGroup
DirectoryIterator::getInode
DirectoryIterator::getMTime
DirectoryIterator::getOwner
DirectoryIterator::getPath
DirectoryIterator::getPathname
DirectoryIterator::getPerms
DirectoryIterator::getSize
DirectoryIterator::getType
DirectoryIterator::isDir
DirectoryIterator::isDot
DirectoryIterator::isExecutable
DirectoryIterator::isFile
DirectoryIterator::isLink
DirectoryIterator::isReadable
DirectoryIterator::isWritable
DirectoryIterator::key
DirectoryIterator::next
DirectoryIterator::rewind
DirectoryIterator::valid
FilterIterator::current
FilterIterator::getInnerIterator
FilterIterator::key
FilterIterator::next
FilterIterator::rewind
FilterIterator::valid
LimitIterator::getPosition
LimitIterator::next
LimitIterator::rewind
LimitIterator::seek
LimitIterator::valid
ParentIterator::getChildren
ParentIterator::hasChildren
ParentIterator::next
ParentIterator::rewind
RecursiveDirectoryIterator::getChildren
RecursiveDirectoryIterator::hasChildren
RecursiveDirectoryIterator::key
RecursiveDirectoryIterator::next
RecursiveDirectoryIterator::rewind
RecursiveIteratorIterator::current
RecursiveIteratorIterator::getDepth
RecursiveIteratorIterator::getSubIterator
RecursiveIteratorIterator::key
RecursiveIteratorIterator::next
RecursiveIteratorIterator::rewind
RecursiveIteratorIterator::valid
SimpleXMLIterator::current
SimpleXMLIterator::getChildren
SimpleXMLIterator::hasChildren
SimpleXMLIterator::key
SimpleXMLIterator::next
SimpleXMLIterator::rewind
SimpleXMLIterator::valid
class_implements
class_parents
iterator_count
iterator_to_array
spl_autoload_call
spl_autoload_extensions
spl_autoload_functions
spl_autoload_register
spl_autoload_unregister
spl_autoload
spl_classes
spl_object_hash
eXTReMe Tracker