php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14002 array_merge of subarrays deletes subarrays of unmerged data
Submitted: 2001-11-09 18:17 UTC Modified: 2001-11-16 13:12 UTC
From: aulbach at unter dot franken dot de Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.4pl1 OS: unix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aulbach at unter dot franken dot de
New email:
PHP Version: OS:

 

 [2001-11-09 18:17 UTC] aulbach at unter dot franken dot de
Example script is also @  http://dev0.fidion.de/ssilk/test/err_array_merge.php

This behavior takes me now 2 hours... Perhaps it is fixed with 4.0.6? Sorry, no testing machine available.

<?php
$a=array(
    'ERROR' => array(
        'tags in text-text' => array(
            'err' => 'tags',
            'type'=> 'nachts'
        ),
        'range-ax-Erscheinungsdatum' => array(
            'err' => 'bla',
            'type' => 'blubb'
        )
    ),
    'WARN' => array(
        'ax-Anzeigenextra' => array(
            'err' => 'hugo',
            'type' => 'sex'
        )
    )
);

echo "<pre>";
echo "BUG:\n";
foreach ($a as $key => $val) {
    if ( empty($this->totalerrs[$key]) ) {
        $totalerrs[$key]=array();
    } 
    foreach ( $val as $k => $v) {
        print_r($v);
        $totalerrs[$key]=
                  array_merge($totalerrs[$key],$val);
    }
}

echo "\n\nFIX:\n";
foreach ($a as $key => $val) {
    if ( empty($this->totalerrs[$key]) ) {
        $totalerrs[$key]=array();
    } 
    $x=$val;
    foreach ( $val as $k => $v) {
        print_r($v);
        $totalerrs[$key]=
                  array_merge($totalerrs[$key],$x);
    }
}

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-16 13:12 UTC] aulbach at unter dot franken dot de
Could just test it 4.0.6 and it works. :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 17:01:30 2025 UTC