php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14128 array_merge_recursive modifies the first argument
Submitted: 2001-11-19 19:01 UTC Modified: 2002-02-26 21:43 UTC
From: petert at tebault dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: Windows NT 4.0 build 1381
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: petert at tebault dot org
New email:
PHP Version: OS:

 

 [2001-11-19 19:01 UTC] petert at tebault dot org
<?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);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-26 21:43 UTC] yohgaki@php.net
The version of PHP that this bug was reported in is too old. Please
try to reproduce this bug in the latest version of PHP (available
from http://www.php.net/downloads.php

If you are still able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 05:01:23 2019 UTC