title: I need to build an array with items that are determined in a loop using a variable.
body: <p>Hello and thank you for looking at this. I am at the limits of my ability and want to figure this out, so I am sorry if this is a newb question.</p>
  
  <p>I am using a word press loop and assigning the first div element an ID using this...</p>
  
  <pre><code>$this_page_id=$wp_query-&gt;post-&gt;ID;
  $item_id = $post-&gt;post_name;
  </code></pre>
  
  <p>and in the div...</p>
  
  <pre><code>&lt;div id="&lt;?php echo $item_id ; ?&gt;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>What I am looking for is at the end of the loop I want to build an array with each id in the array starting from the first id to the last.</p>
  
  <p>So if there were 3 of the dive elements with the id st with $item_id like this...</p>
  
  <pre><code>&lt;div id="item-1"&gt;&lt;/div&gt;
  &lt;div id="item-2"&gt;&lt;/div&gt;
  &lt;div id="item-3"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>my array would look like this...</p>
  
  <pre><code>$items = array("item-1","item-2","item-3")
  </code></pre>
  
  <p>After that I would use a foreach loop to split them up and run conditions on them, that part I get, it is the building the array that has me stumped. </p>
  
  <p>I am hoping someone can point me in the right direction, would like to learn how to do this as it might be handy in the future.</p>
  
  <p>Thank you again and I apologize if this is to simple a question to ask here.</p>