JArrayHelper/toInteger: Difference between revisions
From Joomla! Documentation
m removing red link to edit, no existant pages |
m clean up |
||
| Line 2: | Line 2: | ||
Function to convert array to integer values | Function to convert array to integer values | ||
<! removed transcluded page call, red link never existed > | <! removed transcluded page call, red link never existed > | ||
| Line 52: | Line 50: | ||
</source> | </source> | ||
<! removed transcluded page call, red link never existed > | <! removed transcluded page call, red link never existed > | ||
Revision as of 13:39, 24 March 2017
Description
Function to convert array to integer values
<! removed transcluded page call, red link never existed >
Syntax
static toInteger(&$array, $default=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| &$array | $array The source array to convert | |
| $default | null | array) to assign if $array is not an array |
Defined in
libraries/joomla/utilities/arrayhelper.php
Importing
jimport( 'joomla.utilities.arrayhelper' );
Source Body
static function toInteger(&$array, $default = null)
{
if (is_array($array)) {
foreach ($array as $i => $v) {
$array[$i] = (int) $v;
}
} else {
if ($default === null) {
$array = array();
} elseif (is_array($default)) {
JArrayHelper::toInteger($default, null);
$array = $default;
} else {
$array = array((int) $default);
}
}
}
<! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />