Last active
July 6, 2016 13:39
-
-
Save AndreiTelteu/2125d955ac85650915d612e26679c89a to your computer and use it in GitHub Desktop.
Small PHP function to apply htmlentities function to an array recursively
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 htmlentities_recursive($code) { | |
if (is_array($code)) | |
{ | |
foreach ($code as &$c) $c = htmlentities_recursive($c); | |
return $code; | |
} | |
return htmlentities($code); | |
} | |
// Usage: | |
echo '<pre style="white-space: pre-wrap;">'; | |
print_r(htmlentities_recursive($array)); | |
echo '</pre>'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment