php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46953 "Allowed memory size..." when doing count() in for
Submitted: 2008-12-27 11:52 UTC Modified: 2008-12-31 21:30 UTC
From: tobi at blackswan dot ch Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.6 OS: *
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: tobi at blackswan dot ch
New email:
PHP Version: OS:

 

 [2008-12-27 11:52 UTC] tobi at blackswan dot ch
Description:
------------
Maybe it's nothing but my stupidness ;)

When I do this ->

$headers = imap_fetch_overview($mbox,$start.":{$end}",0);

for ($i = 0; $i <= count($headers) ; $i++) {
    $headers[$i]->subject="fritz";
}

--> Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 43 bytes) ...

When I do this ->

$headers = imap_fetch_overview($mbox,$start.":{$end}",0);

$temp=count($headers);

for ($i = 0; $i <= $temp ; $i++) {
    $headers[$i]->subject="fritz";
}

--> All fine...

$headers has 3 records...

cheers


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-27 11:53 UTC] tobi at blackswan dot ch
forgot to mention... PHP Version is 5.2.6.
 [2008-12-27 14:35 UTC] colder@php.net
Are you increasing the size of $headers ? because of
$headers[$i] not being defined or something ?

FWIW, you could have simply used foreach($headers as $h) { $h->subject="fritz"; } 
 [2008-12-27 14:42 UTC] tobi at blackswan dot ch
You're right, I can do it this way to. I'm just editing data in a stdclass object.
 [2008-12-31 21:30 UTC] felipe@php.net
.
 [2008-12-31 21:30 UTC] felipe@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 17:01:28 2024 UTC