title: Undefined offset: 1 in laravel
body: <p>I want to return this function but i don't know how to fix it.</p>
  <p><strong>Laravel Controller</strong></p>
  <pre><code>public static function downlines($userid,$level){
        
          $level = '';
           static $array = array();
     
          $select = DB::table('stages')
          -&gt;select('*')
          -&gt;where('spillover_id',$userid)
          -&gt;get();
        
    
              $level++;
              foreach($select as $value){
                  $userid = $value-&gt;member_id;
              $array[$level] .= $userid.',';
                   self::downlines($userid, $level);
              }
                 
  
              
           return $array;
              }
  </code></pre>
  <p>ERROR <strong>Undefined offset: 1</strong></p>
  <pre><code>$array[$level] .= $userid.',';
  </code></pre>
  <p>How to let it's work ?</p>