Skip to content

Instantly share code, notes, and snippets.

@AndreiTelteu
Last active July 6, 2016 13:39
Show Gist options
  • Save AndreiTelteu/2125d955ac85650915d612e26679c89a to your computer and use it in GitHub Desktop.
Save AndreiTelteu/2125d955ac85650915d612e26679c89a to your computer and use it in GitHub Desktop.
Small PHP function to apply htmlentities function to an array recursively
<?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