Bug #14128: array_merge_recursive modifies the first argument
| From: | petert at tebault dot org | Date: | Tue, 20 Nov 2001 00:01:37 +0000 |
| Subject: | Bug #14128: array_merge_recursive modifies the first argument | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-70994@lists.php.net to get a copy of this message | ||
From: petert@tebault.org
Operating system: Windows NT 4.0 build 1381
PHP version: 4.0.6
PHP Bug Type: Arrays related
Bug description: array_merge_recursive modifies the first argument
<?php
// bug report:
// note that $query gets modified by the call to
// array_merge_recursive. This should not be.
//
//
//include('../include/util.inc.php');
function dump_array ($array) {
// doc
// String = dump_array(Array)
// returns a long string containing the array, expanded into a
// nested unordered list.
//statements
if(is_array($array)) {
echo "<ul>";
while(list($key,$val) = each($array)) {
echo "<li>$key => ";
if(is_array($val)) {
echo "$val";
dump_array($val);
} else {
echo "$val";
}
}
echo "</ul>";
} else {
if($array != "") {
echo "<li>[String] = $array";
} else {
echo "<li>Err: No values passed.";
}
}
};
/*
addquery
example input #1
*/
$query =
array("select" => array(
0 => "count(*) as 'cases opened'"
),
"from" => array(
0 => "table_case"
),
"where" => array(
0 => "table_case.creation_time between '%datestart%' and
'%dateend%'"
)
);
/*
example input #2
*/
$option =
array("select" => array(
0 => "table_bus_org.name"
),
"from" => array(
0 => "table_site",
1 => "table_bus_org"
),
"where" => array(
0 => "table_site.objid = table_case.case_reporter2site",
1 => "table_bus_org.objid = table_site.primary2bus_org",
2 => "table_bus_org.objid > 0"
),
"group by" => array(
0 => "table_bus_org.name"
),
"order by" => array(
0 => "count(*)"
)
);
/*
example output
$newquery =
array("select" => array(
0 => "table_bus_org.name",
1 => "count(*) as 'cases opened'"
),
"from" => array(
0 => "table_case",
1 => "table_site",
2 => "table_bus_org"
),
"where" => array(
0 => "table_case.creation_time between '%datestart%' and
'%dateend%'",
1 => "table_site.objid = table_case.case_reporter2site",
2 => "table_bus_org.objid = table_site.primary2bus_org",
3 => "table_bus_org.objid > 0"
),
"group by" => array(
0 => "table_bus_org.name",
),
"order by" => array(
0 => "count(*)",
)
);
*/
dump_array($query);
$newquery = array_merge_recursive($query,$option);
dump_array($query);
//dump_array($option);
//dump_array($newquery);
?>
--
Edit bug report at: http://bugs.php.net/?id=14128&edit=1