我正在尝试创建一个适用于简单数组和嵌套数组的函数。到目前为止,该函数如下所示:
function fnPrepareDataForBrowser($values)
{
$values = array_map('htmlspecialchars', $values);
return $values;
}
它适用于简单的数组 - 例如:
Array
(
[Item ID] => 25469
[Item Desc] => spiral nails, 1"
[Standard Item] => yes
[Entry UOM] => lb
)
但它失败并显示消息“警告:htmlspecialchars() 期望参数 1 是字符串,给定数组...”用于嵌套数组 - 例如:
Array
(
[0] => Array
(
[Item ID] => 25469
[Item Description] => spiral nails, 1"
[Standard Item] => yes
[Entry UOM] => lb
)
[1] => Array
(
[Item ID] => 25470
[Item Description] => finishing screws, 2.5"
[Standard Item] => no
[Entry UOM] => lb
)
[2] => Array
(
[Item ID] => 25576
[Item Description] => paint brush, 3"
[Standard Item] => no
[Entry UOM] => each
)
)
应该对函数进行哪些修改以使其适用于简单数组和嵌套数组?