/*
* 測試参数完整,并格式化数组参数
* 返回 FALSE,
array
public
function
format_array_value(
$a_params
= null,
$a_rule
= null)
{
if
(
is_array
(
$a_params
) && !
empty
(
$a_params
) &&
is_array
(
$a_rule
) && !
empty
(
$a_rule
) )
{
foreach
(
$a_rule
as
$key
=>
$value
)
{
if
(
array_key_exists
(
$key
,
$a_params
))
{
if
(
$value
== 'int'
or
$value
== 'integer')
$a_params
[
$key
] =
intval
(
$a_params
[
$key
]);
elseif
(
$value
== 'string') {
$a_params
[
$key
] =
strval
(
$a_params
[
$key
]);
}
elseif
(
$value
== 'double'
or
$value
== 'float') {
$a_params
[
$key
] = doubleval(
$a_params
[
$key
]);
}
elseif
(
$value
==
"boolean"
) {
$a_params
[
$key
] =
$a_params
[
$key
] ? true : false;
}
elseif
(preg_match(
"/^[%bcdeufFosxX]$/"
,
$value
)){
$a_params
[
$key
] = sprintf(
"%"
.
$value
,
$a_params
[
$key
]);
}
else
{
return
FALSE;
}
}
else
{
return
FALSE;
}
}
return
$a_params
;
}
else
{
return
FALSE;
}
}