List all node titles to better iterate on a list of names I have a content type called Country and I have to verify what countries already exists in db and save the missing ones, comparing to a variable with all countries ($country_list). I am having trouble accessing countries names of my nodes, that are specified as the content type title.
  $country_list = ['Mexico', 'Tanzania', 'Brazil', 'Camaron'];
  $nodes = node_load_multiple(array(), array('type' =&gt; 'country_profile'));
  $nodes_name = node_title_list($nodes);

  foreach ($country_list as $country_name) {
    if (!in_array($nodes_name, $nodes)) {
      // should create new node
    } else {
      // shouldn't do anything
    }
  }


The problem is, when i get the node_title_list() it doesn't return the 'raw title' (see output below)
Output:
    Array
(
    [#theme] =&gt; item_list__node
    [#items] =&gt; Array
        (
            [0] =&gt; &lt;a href=&quot;/discover/country_profiles/tanzania&quot;&gt;Tanzania&lt;/a&gt;
            [1] =&gt; &lt;a href=&quot;/discover/country_profiles/mexico&quot;&gt;Mexico&lt;/a&gt;
        )

    [#title] =&gt; 1
)

How can i do that, so that the output of this list is
Array
        (
            [0] =&gt; &quot;Tanzania&quot;
            [1] =&gt; &quot;Mexico&quot;
        )
If you just need to create the nodes that don't have a specific title (which I guess it's just a country name), you don't need to use node_title_list(), whose purpose is rendering a list of node titles as links. Just load the nodes and check which titles aren't already used.
$country_list = ['Mexico', 'Tanzania', 'Brazil', 'Camaron'];

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'country_profile')
  // Remove the following line if you don't need to get only published nodes.
  -&gt;propertyCondition('status', NODE_PUBLISHED)
  // Keep the following line, so Drupal won't check if the currently logged-in user has access to the nodes and the fields.
  -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $query-&gt;execute();
if (isset($result['node'])) {
  $country_list = array_flip($country_list);
  $nodes = entity_load('node', array_keys($result['node']));
  foreach ($nodes as $node) {
    unset($country_list[$node-&gt;title]);
  }
  $country_list = array_flip($country_list);
}

if (!empty($country_list)) {
  // There are nodes that need to be created; their titles are in $country_list.
}

Even better, load those nodes whose title is equal to one of the country names you already have.
$country_list = ['Mexico', 'Tanzania', 'Brazil', 'Camaron'];

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'country_profile')
  // Remove the following line if you don't need to get only published nodes.
  -&gt;propertyCondition('status', NODE_PUBLISHED)
  -&gt;propertyCondition('title', $country_list)
  // Keep the following line, so Drupal won't check if the currently logged-in user has access to the nodes and the fields.
  -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $query-&gt;execute();
if (isset($result['node'])) {
  $country_list = array_flip($country_list);
  $nodes = entity_load('node', array_keys($result['node']));
  foreach ($nodes as $node) {
    unset($country_list[$node-&gt;title]);
  }
  $country_list = array_flip($country_list);
}

if (!empty($country_list)) {
  // There are nodes that need to be created; their titles are in $country_list.
}