Skip to content

Instantly share code, notes, and snippets.

@richardprice-1990
Created February 6, 2018 11:59
Show Gist options
  • Save richardprice-1990/9be705fcb10f20a8eccfee423275e16d to your computer and use it in GitHub Desktop.
Save richardprice-1990/9be705fcb10f20a8eccfee423275e16d to your computer and use it in GitHub Desktop.
//orignal
function spanify_title($title) {
$title_words = explode(' ', $title);
if (count($title_words) > 1) {
$title_words[1] = '<span>' . $title_words[1] . '</span>';
return implode(' ', $title_words);
} else {
return $title;
}
}
//new
function spanify_title($title) {
$title_words = explode(' ', $title, 2);
if (count($title_words) > 1) {
$title_words[1] = '<span>' . $title_words[1] . '</span>';
return implode(' ', $title_words);
} else {
return $title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment