note 61710 deleted from function.array-splice by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 14:55:24 +0000 |
| Subject: | note 61710 deleted from function.array-splice by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197239@lists.php.net to get a copy of this message | ||
Note Submitter: gerry-03 at 4warding dot com
----
For anybody who is wondering... jrhardytwothousandtwo's trick for inserting an element using
array_splice, will also work with multi-dimensional arrays if you do the following:
<?php
function array_insert(&$input, $offset, $replacement){
array_splice($input, $offset, 0, 0);
$input[$offset] = $replacement;
}
?>
I'm not sure if this (or a derivative of it) will solve other problems that I have seen just
about everybody on here trying to solve. But apart from it's hackish nature, it works well for
me.