Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $result_set = Array
- (
- [0] => Array
- (
- [home_id] => 1
- [address] => 4225 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 76798
- )
- [1] => Array
- (
- [home_id] => 8
- [address] => 4229 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 75093
- )
- );
- // this doesn't work since $result_set is an array of arrays and htmlspecialchars is expecting a string
- htmlspecialchars($result_set, ENT_QUOTES, 'UTF-8'));
- array_walk_recursive($result_set, "htmlspecialchars", array(ENT_QUOTES,'UTF-8'))
- function cleanOutput(&$value) {
- return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
- }
- print_r($result_set);
- print('-------');
- print_r(array_walk_recursive($result_set, "cleanOutput"));
- Array
- (
- [0] => Array
- (
- [home_id] => 1
- [address] => 4225 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 76798
- )
- [1] => Array
- (
- [home_id] => 8
- [address] => 4229 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 75093
- )
- )
- -------1
- function cleanOutput(&$value) {
- return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
- }
- $result_set = Array
- (
- [0] => Array
- (
- [home_id] => 1
- [address] => 4225 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 76798
- )
- [1] => Array
- (
- [home_id] => 8
- [address] => 4229 Nasmyth Dr
- [city] => Plano
- [state] => TX
- [zip] => 75093
- )
- );
- $cleanedOutput = array();
- foreach ($result_set as $rs) {
- $cleaned[] = array_map("cleanOutput", $rs);
- }
- print_r($cleanedOutput);
- {'homes' : []}
- function filter(&$value) {
- $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
- }
- array_walk_recursive($result_set, "filter");
- print_r($result_set);
- $cleaned = array_map("htmlspecialchars", $myArray);
- function myFunc($a) {
- return htmlspecialchars($a, ENT_QUOES);
- }
- $cleaned = array_map("myFunc", $myArray);
- $cleaned = array();
- foreach ($result_set as $rs) {
- foreach ($rs as $r) {
- $cleaned[] = array_map("htmlspecialchars", $r);
- }
- }
- array_walk_recursive($myArray, "htmlspecialchars");
- $clean_array = array_map("htmlspecialchars", $myArray, array(ENT_QUOTES, 'UTF-8'));
- $clean_array = array_map("htmlspecialchars", $myArray, array(ENT_QUOTES), array('UTF-8'));
- function secure($val) {
- return (is_array($val))?array_map('secure',$val):htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
- }
- function cleanhtml($dirtyhtml) {
- return htmlspecialchars($dirtyhtml, UTF-8);
- }
- $cleaned = array_map("cleanhtml", $myArray);
- function htmlspecialchars_array_modify (&$arr){
- array_walk_recursive($arr,function(&$value){
- $value=htmlspecialchars($value);
- });
- return $arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement