Jump to content

Help maintaining a count ?


livewirerules

Recommended Posts

$count=0;
$numb=50;
foreach ($sepkeys as $dbkey)
{
for ($page=10;$page<=$numb;$page=$page + 10)
	{
// the if block

$count=$count+1;

}

}

I am trying to maintain a separate a count for each key number in the above code.

 

Eg: key- 574, it searches from pages 10-50 and increments the count by 1.

 

The problem that I have is the count is continuous. After searching for the first key and moves on to the next key and them I need the count to start from the beginning rather than being continuous.

 

Eg: key-874 : count = 22, in my case the next key 875 : the count is 23

 

I need to make it 1.

 

I removed the if block and several lines because the code is too long.

 

Can someone please suggest me a way how to do it

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/210288-help-maintaining-a-count/
Share on other sites

Um, kind of confused, but like this:

 

$count=0;
$numb=50;
foreach ($sepkeys as $dbkey)
{
   for ($page=10;$page<=$numb;$page=$page + 10)
   {
      // the if block
      $count=$count+1;
   }
   $count = 0;
}

 

You need a better explanation.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.