get_node_by_name()

Description

Search an array of nodes by name

Useful to avoid querying the database multiple times
if we already have a full detail array of nodes

Parameters

ColumnTypeDefaultDescription
$nodes array Nodes array as returned by get_nodes()
$name string Filter by name of node
$i18n boolean true Use the translated option value?

Return

array

Location

include/node_functions.php lines 1763 to 1784

Definition

 
function get_node_by_name(array $nodes$name$i18n true)
{
    if (
== count($nodes) || is_null($name) || '' == trim($name)) {
        return array();
    }

    
$name mb_strtolower($name);

    foreach (
$nodes as $node) {
        
$option $node['name'];

        if (
$i18n) {
            
$option i18n_get_translated($node['name']);
        }

        if (
$name === mb_strtolower($option)) {
            return 
$node;
        }
    }

    return array();
}

This article was last updated 21st April 2025 10:35 Europe/London time based on the source file dated 17th April 2025 12:45 Europe/London time.