title: PHP Check if a value is part of sequence of numbers with common difference
body: <p>I'm writing a script that needs to identify every 7th number where the first number of the sequence is 0 (so the sequence is 6, 13, 20, 27, 34, 41, 48, etc.)</p>
  
  <p>Here's what I've got so far (which works in a limited way), but I'd prefer to write a loop so that the values in the sequence don't have to be hardcoded:</p>
  
  <pre><code>&lt;?php
  
  $x = 7;
  
  if ($x === 6 || $x === 13 || $x === 20 || $x === 27 || $x === 34 || $x === 41 || $x === 48) {
      $result = 1;
    } else {
      $result = 0;
  }
  
  echo $result;
  
  ?&gt;
  </code></pre>
  
  <p>Thanks in advance for any advice!</p>
  
  <hr>
  
  <p>Update: Here's my updated script using @robbieaverill 's solution and checking the values against an array.  There are many great solutions here, thanks everyone!</p>
  
  <pre><code>&lt;?php
  
  $divisor = 7;
  $limit = 500; 
  
  $sequence = array();
  
  for ($i = 0; $i &lt;= $limit; $i++) {
    if (is_int(($i + 1) / $divisor)) {
      $sequence[] = $i;
    }
  }
  
  $x = 41;
  
  if (in_array($x, $sequence, true)) {
    $result = 1;
  } else {
    $result = 0;
  }
  
  echo $result;
  ?&gt;
  </code></pre>
  
  <p>The output here is 1, indicating that if the value of $x is 41 it is found within the $sequence array.</p>