I have a bit of a tricky situation here....
I am pulling bookmarks from a service called Pinboard using their API's which works great - but - the category of the 'tag' (i.e. bookmark tag) is echoed out in full with hyphens.
The difficulty I am having is that I'd like the $tag in one instance to retain the hyphens (to allow for an anchor link using markup to work) - whilst - changing the same $tag that is echoed in the < h1 >
So for example one of the $tag is 'Latest-News' - and I'd like that $tag to be printed like this:
for the anchor tag: $tag will echo 'latest-news'
for the < h1 > tag: $tag will echo 'Latest News'
Any ideas how this is done?
Something like this might be on the right track (I hope! - I'm still clearly a n00b):
$str = str_replace("-", " ", $tag);
echo $tag;
+++++
include 'pinboard-api.php';
$pinboard = new PinboardAPI('myusername', 'xxxxxxx');
$bookmarks_all = $pinboard->get_all();
$bookmarks_grouped_by_tags = array();
foreach ($bookmarks_all as $bookmark) {
if (! empty($bookmark->tags) && is_array($bookmark->tags)) {
foreach ($bookmark->tags as $tag) {
$bookmarks_grouped_by_tags[$tag][] = $bookmark;
}
} else {
$bookmarks_grouped_by_tags['no_tag'][] = $bookmark;
}
}
?>
<?php foreach ($bookmarks_grouped_by_tags as $tag => $bookmarks) { ?>
<a name="<?php echo $tag ?>">
***** <h1><?php echo $tag ?></a></h1> *******
<? foreach ($bookmarks as $bookmark) { ?>
<div>
<a href="<?php echo $bookmark->url ?>"><?php echo $bookmark->title ?></a>
</div>
<div><?php echo $bookmark->description ?></div>
<?php } ?>
<?php } ?>
++++