|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-11-21 09:19 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2016-11-21 09:19 UTC] requinix@php.net
[2016-11-21 09:36 UTC] spam2 at rhsoft dot net
[2016-11-21 09:46 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 02:00:01 2025 UTC |
Description: ------------ since you depreacte each() with PHP 7.2 better fix foreach() before [harry@srv-rhsoft:/downloads]$ php each.php Extract: 0.031516075134277 While: 0.0004878044128418 For-Each: 0.11238217353821 Test script: --------------- [harry@srv-rhsoft:/downloads]$ cat each.php <?php $loops = 2000; for($x=1;$x<$loops;$x++) { $arr['key' . $x] = 'Test'; } echo "Extract: "; $start = microtime(true); for($x=1;$x<$loops;$x++) { extract($arr, EXTR_SKIP); } echo microtime(true) - $start . "\n"; echo "While: "; $start = microtime(true); for($x=1;$x<$loops;$x++) { while(list($key,$value)=each($arr)) { ${$key} = $value; } } echo microtime(true) - $start . "\n"; echo "For-Each: "; $start = microtime(true); for($x=1;$x<$loops;$x++) { foreach($arr as $key=>$value) { ${$key} = $value; } } echo microtime(true) - $start . "\n"; ?>