#19617 [Ver->Bgs]: Array_multisort don't work on GLOBAL array
| From: | sniper@php.net | Date: | Mon, 08 Sep 2003 12:48:02 +0000 |
| Subject: | #19617 [Ver->Bgs]: Array_multisort don't work on GLOBAL array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47246@lists.php.net to get a copy of this message | ||
ID: 19617
Updated by: sniper@php.net
Reported By: jpapin at free dot fr
-Status: Verified
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Unix
PHP Version: 4.3.3-dev 5.0.0b2
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.
Thank you for your interest in PHP.
See bug #25359 (more recent)
Previous Comments:
------------------------------------------------------------------------
[2003-06-08 04:45:12] jpapin at free dot fr
A nice guy from Germany want me to turn the bug open again.
------------------------------------------------------------------------
[2003-05-13 07:19:03] matschek at gmx dot de
Another hint:
if you pass the $data as a reference [for my example above:
'array_multisort($sort, &$data);'], it works - but this is deprecated,
so this cant be the solution..
------------------------------------------------------------------------
[2003-05-13 07:03:27] matschek at gmx dot de
Tested with PHP 4.3.1, same problem:
Globalized arrays cannot be sorted using array_multisort, although the
functions returns TRUE!
Another short piece of code to test:
<?
function test() {
global $data;
$data= array("first", "fifth", "second", "forth",
"third");
$sort= array(1,5,2,4,3);
array_multisort($sort, $data);
print_r($data);
}
test();
?>
Without "global $data;" it works fine.
------------------------------------------------------------------------
[2002-09-26 11:14:55] sniper@php.net
Works fine here with latest CVS head.
Please, try PHP 4.2.3. (4.2.0 is really too old..)
------------------------------------------------------------------------
[2002-09-26 11:11:59] jpapin at free dot fr
Sorry, try this with and without "global $row;"
<?
function t() {
global $row;
$row =
array(array("1","Php"),array(2,"I"),array(3,"Love"));
foreach ( $row as $value ) {
$sortarray[] = $value[1];
}
array_multisort($sortarray,$row);
print_r($row);
echo "<br>";
print_r($sortarray);
}
t();
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/19617
--
Edit this bug report at http://bugs.php.net/?id=19617&edit=1