Last active
May 20, 2018 10:37
-
-
Save mdjwel/213785b81df6467de67e0beb2d37c582 to your computer and use it in GitHub Desktop.
Convert a special sign to HTML Tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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