Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

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 1595 to 1620

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 12th July 2020 03:35 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.