Difference between revisions of "JArrayHelper/getColumn"
From Joomla! Documentation
< API16:JArrayHelper
m (removing red link to edit, no existant pages) |
|||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 59: | Line 59: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 74: | Line 74: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 21:49, 12 May 2013
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
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[edit]
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[edit]
array Column of values from the source array
Defined in[edit]
libraries/joomla/utilities/arrayhelper.php
Importing[edit]
jimport( 'joomla.utilities.arrayhelper' );
Source Body[edit]
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[edit]
<CodeExamplesForm />