Last active
January 3, 2016 03:39
-
-
Save fenixkim/8403948 to your computer and use it in GitHub Desktop.
Same than `kirbytext()` but only allows the tags in `allowedTags`
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 | |
/** | |
* Same than `kirbytext()` but only allows the tags in `allowedTags` | |
* | |
* <code> | |
* | |
* $text = 'This is a html text with a **strong** and *em* text'; | |
* | |
* // Remove all tags except strong tags | |
* cleanKirbytext($text, '<strong>'); | |
* // output: This is a html text with a <strong>strong</strong> and em text | |
* | |
* <code> | |
* | |
* @param string $text The normal text. | |
* @param string $allowdTags The list of allowed tags as is described here: http://php.net/manual/es/function.strip-tags.php | |
* | |
*/ | |
function cleanKirbytext($text, $allowedTags = '') { | |
return strip_tags(kirbytext($text), $allowedTags); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment