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' => '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] => item_list__node
[#items] => Array
(
[0] => <a href="/discover/country_profiles/tanzania">Tanzania</a>
[1] => <a href="/discover/country_profiles/mexico">Mexico</a>
)
[#title] => 1
)
How can i do that, so that the output of this list is
Array
(
[0] => "Tanzania"
[1] => "Mexico"
)