title: Why below function returning me null instead of 1?
body: <p>I have written below function to process an array but It is not returning me 1 thought It's output $input[0] returning me 1. don't understand why It is return NULL. Anything I return in that condition is return me NULL. Please explain me if anyone know. Thanks.</p>
  
  <pre><code>function endWithNumber($input)
  {
      if (count(array_unique($input)) === 1) {        
          return $input[0];       
      }
      $maxVal = max($input);
      $maxKey = array_search($maxVal,$input);
  
      foreach ($input as $k =&gt; $v) {
          if ($maxKey != $k &amp;&amp; $maxVal != $v) {
              $newVal  = ($maxVal - $v);
              $input[$maxKey] = $newVal;
              break;
          }
      }
  
      endWithNumber($input);
  }
  
  $input = array(6,10,15);  
  var_dump(endWithNumber($input));
  exit;
  </code></pre>