title: PHP list to an Array to a foreach Joomla Module
body: <p>I have the following PHP, that needs to take a list of article ids and run it through a function to get them all from the database.</p>
  
  <p>I am very much a beginner in PHP so far I have:</p>
  
  <pre><code>list($slide1, $slide2, $slide3, $slide4, $slide5) = explode(" ", $params-&gt;get('id'));
  
  $a = array(
      $item =&gt; $slide1,
      "two" =&gt; $slide2,
  //    "three" =&gt; $slide3,
  //    "four" =&gt; $slide4,
  //  "five" =&gt; $slide5
  );
  
  foreach ($a as $k) {
      $args['id'] = $k;
      $item = ModArticleSlider::getArticles($args);
  }
  </code></pre>
  
  <p>and the class:</p>
  
  <pre><code>class ModArticleSlider {
  
      public function getArticles($args){
          $db = &amp;JFactory::getDBO();
          $item = "";
  
          $id = $args['id'];
          if($id &gt; 0){
  
              $query  = "select * ";
              $query .= "FROM #__content  WHERE id =".$id." AND state=1 " ;
  
              //echo $query;
              $db-&gt;setQuery($query);
              $item = $db-&gt;loadObject();
          }
  
          return $item;
      }
  
  }
  </code></pre>
  
  <p>How would i get it so that instead of specifying $item to have it almost dynamic so that i can get all the selected articles and place them in different variables.. or would i have to place them in a array?</p>
  
  <p>Any Advice/Answers Greatly Appreciated. </p>