php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13317 Optimizing Bug for 'sizeof' function
Submitted: 2001-09-15 10:56 UTC Modified: 2001-09-15 16:05 UTC
From: mladdens at eunet dot yu Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 4.0.6 OS: Unix/Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mladdens at eunet dot yu
New email:
PHP Version: OS:

 

 [2001-09-15 10:56 UTC] mladdens at eunet dot yu
There is a huge diference in speed with these two approaches:

$file=file("file.txt");

1.
 for($i=0;$i<sizeof($file);$i++)
   ...

2.
$file_size=sizeof($file);
 for($i=0;$i<$file_size;$i++)
    ...

The second approach is much more faster, because the first seems to calculate the 'sizeof' in every iteration.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-15 16:05 UTC] joey@php.net
But that is what you have ASKED it to do.
This is the way that for() should behave. Not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC