JUtility/array unshift ref: Difference between revisions
From Joomla! Documentation
No edit summary |
m preparing for archive only |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
Prepend a reference to an element to the beginning of an array. Renumbers numeric keys, so $value is always inserted to $array[0] | Prepend a reference to an element to the beginning of an array. Renumbers numeric keys, so $value is always inserted to $array[0] | ||
===Syntax=== | ===Syntax=== | ||
| Line 44: | Line 42: | ||
</source> | </source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=array_unshift_ref | category=array_unshift_ref | ||
category=JUtility | category=JUtility | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:16, 25 March 2017
Description
Prepend a reference to an element to the beginning of an array. Renumbers numeric keys, so $value is always inserted to $array[0]
Syntax
array_unshift_ref(&$array, &$value)
| Parameter Name | Default Value | Description |
|---|---|---|
| &$array | array | |
| &$value | mixed |
Returns
int
Defined in
libraries/joomla/utilities/utility.php
Importing
jimport( 'joomla.utilities.utility' );
Source Body
function array_unshift_ref(&$array, &$value)
{
$return = array_unshift($array,'');
$array[0] =& $value;
return $return;
}
Examples
Code Examples