i have a foreach statement which looks like this
foreach(static::$_components as &$field){
..some code
}
in "some code" i sometimes add more components to "static::$_components" member
if the insertion happens not at the final iteration it works, and the foreach detect & use the last insertion.
but if the insertion happens at the last iteration
the foreach statement breaks(ends) without detecting & using the last insertion
there is any workaround for this issue
beside using for loops and count(array).
i prefer using foreach due to performance demands
for($iterator = 0, $field = ''; null != ($field = empty(static::$_components[$iterator]) ? null : static::$_components[$iterator]); $iterator++){
...some code
}
consumes a lot of memory and proccessing time
using
for($iterator = 0; $iterator < count(static::$_components); $iterator++){
...some code
}
is even worse
Thanks in advance