<?php
$data_billding= array(
'first_name' => "<b>hello</b>",
'last_name' => "<i>hello</i>",
'email' => "\hello",
'phone' => "he\llo",
'address' => "<h1>hello</h1>",
);
function change($value, $key){
$key = stripslashes(strip_tags($key));
$value = stripslashes(strip_tags($value));
global $a;
$a[] = array($key => $value);
//print_r($a);
}
array_walk_recursive($data_billding, "change");
print_r($a);
function my_function($value){
return stripslashes(strip_tags($value));
}
/*trả về array chứa value nếu hàm my_function trả về TRUe*/
print_r(array_filter($data_billding,"my_function"));
?>
- Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- Array
(
[0] => Array
(
[first_name] => hello
)
[1] => Array
(
[last_name] => hello
)
[2] => Array
(
[email] => hello
)
[3] => Array
(
[phone] => hello
)
[4] => Array
(
[address] => hello
)
)
Array
(
[first_name] => <b>hello</b>
[last_name] => <i>hello</i>
[email] => \hello
[phone] => he\llo
[address] => <h1>hello</h1>
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => Array
(
[first_name] => hello
)
[1] => Array
(
[last_name] => hello
)
[2] => Array
(
[email] => hello
)
[3] => Array
(
[phone] => hello
)
[4] => Array
(
[address] => hello
)
)
Array
(
[first_name] => <b>hello</b>
[last_name] => <i>hello</i>
[email] => \hello
[phone] => he\llo
[address] => <h1>hello</h1>
)
preferences:
164.48 ms | 403 KiB | 162 Q