logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



php 7.2.0 beta 3 bugs ? The each() function is deprecated

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
spser



Joined: 29 Aug 2016
Posts: 28

PostPosted: Wed 23 Aug '17 9:25    Post subject: php 7.2.0 beta 3 bugs ? The each() function is deprecated Reply with quote

Code:
<?php
$foo = array("Robert" => "Bob", "Seppo" => "Sepi");
$bar = each($foo);


Error:
-------------------------
Type: E_DEPRECATED[8192]
Mess: The each() function is deprecated. This message will be suppressed on further calls

Find solutions
Back to top
Mandrake



Joined: 11 Dec 2013
Posts: 3
Location: Denmark, Copenhagen

PostPosted: Wed 23 Aug '17 9:45    Post subject: Reply with quote

You should probably use foreach instead or perhaps iterators if you need more control of the looping.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 794
Location: Amsterdam, NL, EU

PostPosted: Thu 24 Aug '17 8:59    Post subject: Reply with quote

Or fool yourself and silence the warning:

Code:
<?php
$foo = array("Robert" => "Bob", "Seppo" => "Sepi");
$bar = @each($foo);

This is likely to fail in PHP 7.3 or 8.0, so you'd better switch to foreach(), array_keys() / array_values() or something like that.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1