I am currently writing a class which is going to handle output from other objects. The class constructs a numeric array at the first dimension with HTML "fields", containing tag, attributes and content. Content will be then a numeric array again for HTML tags nesting. If 'Tag'
is NULL, it is considered direct text.
$output = array( //Numeric array
array( //Associative array
'Tag' => 'h3',
'Attributes' => 'id=SomeTitle',
'Contents' => array (), //Numeric array again, same as first dimension,
),
array( //Associative array
'Tag' => 'p',
'Attributes' => 'id=someID',
'Contents' => array (), //Numeric array again, same as first dimension
),
);
The question now is: is there an easy way to insert data on an already defined position? Let's say I want a new associative array to be placed in $output[1]
and all other indexes equal and higher then to be incremented by one.
I know that I could write a method that iterate over the array in reverse and increase all those indexes. It's just that I'm wondering if I overlooked anything in the PHP handbook, that handles the same thing.