|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-11 18:10 UTC] colder@php.net
[2008-05-11 20:28 UTC] phpbugs at rjharrison dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 10 15:00:01 2025 UTC |
Description: ------------ When looping over a $directorIterator using FOREACH something goes wrong when assigning the "as" variable to an array. Reproduce code: --------------- $filePath = 'PUT YOUR TEST PATH HERE'; $dir = new DirectoryIterator($filePath); $files = array(); foreach ($dir as $file){ $files[] = $file; echo $file->getFilename(), " / ", $file->getSize(), " bytes\n"; } echo "\nSecond loop:-\n"; foreach ($files as $file2){ echo $file2->getFilename(), " / ", $file2->getSize(), " bytes\n"; } Expected result: ---------------- (Depends on the files but assuming a single file in the directory) test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Second run:- test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Actual result: -------------- test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Second run:- / 4096 bytes / 4096 bytes / 4096 bytes