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

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.



Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: php 7.2.0 beta 3 bugs ? The each() function is deprecated
Author
spser



Joined: 29 Aug 2016
Posts: 62

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: 4
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: 982
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


Reply to topic   Topic: php 7.2.0 beta 3 bugs ? The each() function is deprecated View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner