Skip to content

Instantly share code, notes, and snippets.

@jgarciaruiz
Created March 15, 2019 11:20
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 jgarciaruiz/4d9765e698c66d8b7113f51edcde02b0 to your computer and use it in GitHub Desktop.
Save jgarciaruiz/4d9765e698c66d8b7113f51edcde02b0 to your computer and use it in GitHub Desktop.
php: bold text between pipes
<?php
function boldText($text){
$regxpattern = '#\|(.*?)\|#';
$html = preg_replace($regxpattern, '<strong>$1</strong>', $text);
return $html;
}
$str = 'lorem ipsum |dolor| sit amet';
echo boldText($str);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment