PHP 8.5.0 Released!

Voting

: nine minus six?
(Example: nine)

The Note You're Voting On

Vasily Yudin (st-2 at mail dot ru)
11 years ago
If you do current() after using uset() on foreach statement, you can get FALSE in PHP version 5.2.4 and above.
There is example:
<?php
$prices = array(
 0 => '1300990',
 1 => '500',
 2 => '600'
);
foreach($prices as $key => $price){
 if($price < 1000){
 unset($prices[$key]);
 }
}
var_dump(current($prices)); // bool(false)
?>
If you do unset() without foreach? all will be fine.
<?php
$prices = array(
 0 => '1300990',
 1 => '500',
 2 => '600'
);
unset($prices[1]);
unset($prices[2]);
var_dump(current($prices));
?>

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /