-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing while iterating #20
Comments
You are absolutely right - this does not have the same behaviour as the PHP array, which if I understand correctly updates its own internal traversal pointer during I haven't looked at this code in a while (on vacation still) but there will be a solution coming your way. Thanks for bringing this up. 👍 <?php
class Foo {
public $bar;
public function __construct($bar) {
$this->bar = $bar;
}
}
$set = [];
for ($i = 0; $i<=9; $i++) {
$set[] = new Foo($i);
}
foreach ($set as $key => $value) {
echo $value->bar;
}
echo PHP_EOL;
foreach ($set as $value) {
if(($key = array_search($value, $set)) !== false) {
unset($set[$key]);
}
}
echo PHP_EOL;
var_dump($set);
|
See #17 |
I'm trying to find something fast to write a LINQ php like library, php-ds got me out of programming hell. |
Closing in favour of #17 |
New (and awsome) data structures but still php, this should work 😋
The text was updated successfully, but these errors were encountered: