...

View Full Version : Lower Count In An Array



kochier
07-31-2008, 11:32 PM
Basically I have an if statement that goes
if ($cdate3 == $mdate2)
{
}

And I want it to lower the count of the array by 1 whenever they are equal
if ($cdate3 == $mdate2)
{
count($arry)--;
}

However I'm not sure how to do this. Help is greatly appreciated.

oesxyl
07-31-2008, 11:40 PM
Basically I have an if statement that goes
if ($cdate3 == $mdate2)
{
}

And I want it to lower the count of the array by 1 whenever they are equal
if ($cdate3 == $mdate2)
{
count($arry)--;
}

However I'm not sure how to do this. Help is greatly appreciated.
you want de remove a item from array each time the condition is true? first or last or don't matter?


if($cdate3 == $mdate2){
array_pop($arry); // last removed, count decremented
array_shift($arry); // first removed, count will be decremented
}

regards

kochier
07-31-2008, 11:47 PM
Thanks, works perfectly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum