RE: [PHP] Array_Push but instead of putting it at the end...
| From: | Boget, Chris | Date: | Wed, 13 Dec 2000 18:30:22 +0000 |
| Subject: | RE: [PHP] Array_Push but instead of putting it at the end... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30453@lists.php.net to get a copy of this message | ||
> I would like to add to an array like array_push, but instead
> of adding it to the end of the stack, I want to add it to the
> front and push everything in the array back on spot.
I don't have web access right now :( to check the PHP site to
see if there is a function already existing that does this, but
something like the following would work:
function addToStart( $array, $value ) {
$retval = array( $value );
for( $i = 0; $i < count( $array ); $i++ ) {
$retval[] = $array[$i];
}
return $retval;
}
Chris