Skip to content

Instantly share code, notes, and snippets.

@keeprock
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keeprock/98ce632c8c9134302bd1 to your computer and use it in GitHub Desktop.
Save keeprock/98ce632c8c9134302bd1 to your computer and use it in GitHub Desktop.
Use Regex to replace text between HTML tags
preg_match('/>([^<]*)/i', $bread_item, $text);
$bread_item_text = preg_replace("/&#?[a-z0-9]+;/i", "", $text[1]);
$bread_item_text = '>' . truncate_utf8($bread_item_text, 50, TRUE, TRUE, 1) . '<';
$bread_item_text = preg_replace('/>[^<]*</i', $bread_item_text, $bread_item);
$breadcrumb[$key] = $bread_item_text;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment