The way I see it, you have two ways to avoid that error:
1) If you want to preserve indexes:
foreach ($array as $index => $name)
{
if ($name->currentHP >0)
{
$newarray[$index] = $name;
}
}
2) If you don't care about indexes at all
foreach ($array as $name)
{
if ($name-
Jeff Taylor wrote:
Is it possible to just add a value to the existing? here is my current
script:
foreach ($newarray as $name)
{
$newarray[$name] = $name->currentInitiative =
rand(1,$name->GetInitiative()));
}
// sort array by ranking (initiative)
sort($newarray,SORT_NUMERIC);
Is it possible to just add a value to the existing? here is my current
script:
foreach ($newarray as $name)
{
$newarray[$name] = $name->currentInitiative =
rand(1,$name->GetInitiative()));
}
// sort array by ranking (initiative)
sort($newarray,SORT_NUMERIC);
can I change the $new
3 matches
Mail list logo