API16

JArrayHelper/toInteger: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Function to convert array to integer values <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JArrayHelper/toInteger|Edit Descripton]...
 
Doxiki (talk | contribs)
No edit summary
Line 17: Line 17:
!Description
!Description
|-
|-
|  
| &$array
|  
|  
|  $array The source array to convert  
|  $array The source array to convert  

Revision as of 10:19, 30 March 2010

Description

Function to convert array to integer values

[Edit Descripton]

Template:Description:JArrayHelper/toInteger

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);
                }
        }
}

[Edit See Also] Template:SeeAlso:JArrayHelper/toInteger

Examples

<CodeExamplesForm />