title: How to get only the first instance of an array that is true of a condition
body: <p>I'm new to PHP and I'm trying to modify my Wordpress-based Learning Management theme (called Academy on ThemeForest) to be able to work out which lesson in the current course the user is up to. </p>
  
  <p>In other words, I want to run a check to see which lessons the user has completed, getting only the ID of the first lesson in the course hierarchy that has not been completed.</p>
  
  <p>Here's everything I know: </p>
  
  <p>Within the loop of a single post (in this case a "course"), this is how I get the array of the current course's lessons:</p>
  
  <pre><code>&lt;?php $lessons_array = ThemexCourse::sortLessons(ThemexCourse::$data['course']['lessons']); ?&gt;
  </code></pre>
  
  <p>This produces this nested array:</p>
  
  <pre><code>Array ( [0] =&gt; WP_Post Object ([ID] =&gt; 117 [menu_order]=&gt;1) [1] =&gt; WP_Post Object ([ID] =&gt; 124 [menu_order]=&gt;2) [2] =&gt; WP_Post Object ([ID] =&gt; 156 [menu_order]=&gt;3))
  </code></pre>
  
  <p>I've truncated it a bit since the two values, [ID] and [menu_order], are the most important: they tell you the ID of each lesson and their hierarchy in the course.</p>
  
  <p>But this is where I get stuck: I don't want to get all of the lesson IDs, just the one the user has yet to complete.</p>
  
  <p>In order to check if a user has completed a lesson or not, I've been using this:</p>
  
  <pre><code>&lt;?php if(ThemexCourse::isCompletedLesson($lesson_ID)) { echo 'Completed'; } ?&gt;
  </code></pre>
  
  <p>So using the above information, is it possible to return a single ID of only the next incomplete lesson?</p>
  
  <p>Thanks to anyone in advance for your help!</p>