title: PHP search in array and if exists increment, else exit and return value
body: <p>I have this type of array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 001
      [1] =&gt; 002
      [2] =&gt; 003
      [3] =&gt; 222
      [4] =&gt; 0002
      [5] =&gt; 0003
      [6] =&gt; 0004
      [7] =&gt; 1000
      [8] =&gt; 2000
      [9] =&gt; 3000
  )
  </code></pre>
  
  <p>And I need to check if a value, "created" on the fly by code itself, exists or not. If not, use it, else increments it of 1 and check again (<em>for several reasons, I cannot pick the biggest number and simply add "1"</em>).</p>
  
  <p>So, I did write this snippet, but I think that it never will exit from cycle and I don't know how re-check again (and again)...</p>
  
  <pre><code>$base_test = 001;
  while (array_key_exists($base_test, $array_start))
  {
       $base_test++;
       // how can I now re-check for this new value?
  }
  </code></pre>