sean commented on a Page, htmlspecialchars() for arrays / nested arrays  -  May 03, 2012

Great example @Typo !
You could also look into using array_walk_recursive. Consider the following:

<?php

function _clean(&$value) {
  $value = htmlspecialchars($value);
}

$a = array(
  1 => '<script />',
  2 => '<div bla="bla&bla2=morebla"',
  3 => array(
    1 => '<script />',
    2 => '<div bla="bla&bla2=morebla"',
  ),
);

array_walk_recursive($a, '_clean');
printf('<pre>%s</pre>', print_r($a, 1));

?>

This route makes things a bit easier if you need add more data cleaning methods :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.