Hello,
I'm playing with the new each() API method.
$warning = $divesites->each(function($item) {
$warning = "";
if (!$item->marker->address) {
$warning .= "<div class='alert alert-warning'>coordinates for {title} not set</div>";
} else {
$warning .= "";
}
return $warning;
});
$warning should return an empty string, when all dive site adresses are set. But instead it returns the page id of the last dive site in the loop.
When I do it the foreach way
$warning = "";
foreach ($divesites as $site) {
if (!$site->marker->address) {
$warning .= "<div class='alert alert-warning'>coordinates for {$site->title} not set</div>";
} else {
$warning .= "";
}
}
the $warning is an empty string as expected.
Why is that? Any pointers would be much appreciated.