Actions

API15

Difference between revisions of "JArrayHelper/getColumn"

From Joomla! Documentation

< API15:JArrayHelper
(New page: ===Description=== Extracts a column from an array of arrays or objects <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JArrayHelper/getColumn|Edit De...)
 
m (removing red link to edit, no existant pages)
 
(One intermediate revision by one user not shown)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JArrayHelper/getColumn|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JArrayHelper/getColumn}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 17: Line 17:
 
!Description
 
!Description
 
|-
 
|-
|  
+
| &$array
 
|  
 
|  
 
|  $array The source array  
 
|  $array The source array  
Line 59: Line 59:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JArrayHelper/getColumn|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JArrayHelper/getColumn}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 74: Line 74:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 08:43, 12 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Extracts a column from an array of arrays or objects

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

getColumn(&$array, $index)
Parameter Name Default Value Description
&$array $array The source array
$index $index The index of the column or name of object property

Returns

array Column of values from the source array

Defined in

libraries/joomla/utilities/arrayhelper.php

Importing

jimport( 'joomla.utilities.arrayhelper' );

Source Body

function getColumn(&$array, $index)
{
        $result = array ();
 
        if (is_array($array))
        {
                $n = count($array);
                for ($i = 0; $i < $n; $i++)
                {
                        $item = & $array[$i];
                        if (is_array($item) && isset ($item[$index])) {
                                $result[] = $item[$index];
                        } elseif (is_object($item) && isset ($item-> $index)) {
                                $result[] = $item-> $index;
                        }
                        // else ignore the entry
                }
        }
        return $result;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />