title: PHP: How to get last array element in one array
body: <p>i am trying to create function to check if array element is the last array element in one array. Original array looks like:</p>
  
  <pre><code>array(1001,
        1002,
        array('exam'=&gt;true, 'index'=&gt;10),
        1003,
        1004,
        1005,
        array('exam'=&gt;true, 'index'=&gt;20),
        1006,
        1007,
        array('exam'=&gt;true, 'index'=&gt;30),
        1008,
        1009
  )
  </code></pre>
  
  <p>I this case to prove if "array('exam'=>true, 'index'=>30)" is the last.</p>
  
  <p>I have index position of that element, but I do not know how to check if that is the last array element.</p>
  
  <pre><code>    function is_last_exam_in_survey($array, $exam_position) {
  
        foreach($array as $element) {
          if(!is_numeric($element) {
            // check if that is the last array element in array
  
            //return true;
          } else {
            // return false;
          }
        }
  
      }
  </code></pre>
  
  <p>I would be grateful for any advice:)</p>