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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.