Reputation: 3021
I am printing using PHP
<?php echo $article->link($article->title()); ?>
This string holds something like
"Team Member - Job Title"
What id like to do is wrap everything after the dash in a span so i can change its colour.
Any help would be greatfully appreciated.
Upvotes: 0
Views: 165
Reputation: 124828
Try this:
<?php
list($a, $b) = explode(' - ', $article->title());
echo $article->link($a.' - <span>'.$b.'</span>');
?>
Upvotes: 2
Reputation: 1178
Not elegant, but fast:
$str = 'Team Member - Job Title' . '</span>';
$str = strtr(
$str,
'-',
'- <span>'
);
Upvotes: 0
Reputation: 20609
preg_replace is probably the easiest way to do this:
preg_replace('/([^-]*\s*-\s*)(.*)/', '\\1<span class="whatever">\\2</span>', $article->link($article->title()) )
Upvotes: 0