PHP 8.5.0 Alpha 4 available for testing

Voting

: max(eight, six)?
(Example: nine)

The Note You're Voting On

benny at whitewashing dot de
17 years ago
I have to correct my implementation from before. The example before only supported correct read-access but failed on setting new values after creation of the ArrayMultiObject. Also i had to correct a bug that occured from my CopyPasteChange into the comment textarea.

This snippet now hopefully implements a fully functional multidimensional array, represented by an ArrayObject:

<?php
class ArrayMultiObject extends ArrayObject
{
function
__construct($array, $flags = 0, $iterator_class = "ArrayIterator")
{
$objects = array();
foreach(
$array AS $key => $value) {
if(
is_array($value)) {
$objects[$key] = new ArrayMultiObject($value, $flags, $iterator_class);
} else {
$objects[$key] = $value;
}
}

parent::__construct($objects, $flags, $iterator_class);
}

public function
offsetSet($name, $value)
{
if(
is_array($value)) {
$value = new ArrayMultiObject($value);
}

return
parent::offsetSet($name, $value);
}
}
?>

<< Back to user notes page

To Top