function dbem_replace_locations_placeholders($format, $location, $target = "html")
{
    $location_string = $format;
    preg_match_all("/#@?_?[A-Za-z]+/", $format, $placeholders);
    foreach ($placeholders[0] as $result) {
        // echo "RESULT: $result <br>";
        // matches alla fields placeholder
        if (preg_match('/#_MAP/', $result)) {
            $map_div = dbem_single_location_map($location);
            $location_string = str_replace($result, $map_div, $location_string);
        }
        if (preg_match('/#_PASTEVENTS/', $result)) {
            $list = dbem_events_in_location_list($location, "past");
            $location_string = str_replace($result, $list, $location_string);
        }
        if (preg_match('/#_NEXTEVENTS/', $result)) {
            $list = dbem_events_in_location_list($location);
            $location_string = str_replace($result, $list, $location_string);
        }
        if (preg_match('/#_ALLEVENTS/', $result)) {
            $list = dbem_events_in_location_list($location, "all");
            $location_string = str_replace($result, $list, $location_string);
        }
        if (preg_match('/#_(NAME|ADDRESS|TOWN|PROVINCE|DESCRIPTION)/', $result)) {
            $field = "location_" . ltrim(strtolower($result), "#_");
            $field_value = $location[$field];
            if ($field == "location_description") {
                if ($target == "html") {
                    $field_value = apply_filters('dbem_notes', $field_value);
                } else {
                    if ($target == "map") {
                        $field_value = apply_filters('dbem_notes_map', $field_value);
                    } else {
                        $field_value = apply_filters('dbem_notes_rss', $field_value);
                    }
                }
            } else {
                if ($target == "html") {
                    $field_value = apply_filters('dbem_general', $field_value);
                } else {
                    $field_value = apply_filters('dbem_general_rss', $field_value);
                }
            }
            $location_string = str_replace($result, $field_value, $location_string);
        }
        if (preg_match('/#_(IMAGE)/', $result)) {
            if ($location['location_image_url'] != '') {
                $location_image = "<img src='" . $location['location_image_url'] . "' alt='" . $location['location_name'] . "'/>";
            } else {
                $location_image = "";
            }
            $location_string = str_replace($result, $location_image, $location_string);
        }
        if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) {
            $events_page_link = dbem_get_events_page(true, false);
            if (stristr($events_page_link, "?")) {
                $joiner = "&amp;";
            } else {
                $joiner = "?";
            }
            $venue_page_link = dbem_get_events_page(true, false) . $joiner . "location_id=" . $location['location_id'];
            $location_string = str_replace($result, $venue_page_link, $location_string);
        }
    }
    return $location_string;
}
<?php 
$location = dbem_get_location($_REQUEST['location_id']);
?>
    		

<table id="events-table">
	<col id="col120" />
	<col id="col190" />
	<thead>
		<tr>
			<th colspan="3"><?php 
echo $location['location_name'];
?>
</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<th class="text-left">Date</th>
			<th class="text-left">Time</th>
			<th class="text-left">Name</th>
		</tr>
		<?php 
echo dbem_events_in_location_list($location);
?>
	</tbody>
</table>
<pre>
<?php 
echo dbem_single_location_map($location);