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]...
 
m preparing for archive only
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:
Function to convert array to integer values
Function to convert array to integer values


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JArrayHelper/toInteger|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JArrayHelper/toInteger}}
 
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 17: Line 15:
!Description
!Description
|-
|-
|  
| &$array
|  
|  
|  $array The source array to convert  
|  $array The source array to convert  
Line 52: Line 50:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JArrayHelper/toInteger|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JArrayHelper/toInteger}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=toInteger
  category=toInteger
  category=JArrayHelper
  category=JArrayHelper
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:19, 25 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

Code Examples