Skip to content

Instantly share code, notes, and snippets.

@mdjwel
Last active May 20, 2018 10:37
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mdjwel/213785b81df6467de67e0beb2d37c582 to your computer and use it in GitHub Desktop.
Convert a special sign to HTML Tag
<?php
function Convert_to_htmlTag($string, $tagSign='|') {
if(strpos($string, '|') == true) {
$firstSign = strpos($string, $tagSign);
$lastSign = strpos($string, $tagSign, $firstSign + 1);
$strArray = str_split($string);
$replaceSigns = array($firstSign => '<span>', $lastSign => '</span>');
$replaceSigns = array_replace($strArray, $replaceSigns);
echo implode($replaceSigns);
}else {
echo $string;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment