note 98299 deleted from function.array-push by joey
| From: | joey@php.net | Date: | Sun, 30 Oct 2011 07:03:21 +0000 |
| Subject: | note 98299 deleted from function.array-push by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184226@lists.php.net to get a copy of this message | ||
Note Submitter: vr72 at yahoo dot com
----
Another way to add an element at the beginning of an array:
// By Vidal RodrÃguez
<?
function array_rpush(&$arr, $item)
{
$arr = array_pad($arr, -(count($arr) + 1), $item);
}
?>
It should be noted that $item can be of any type.