Iterating through a foreach loop - only show 1 item rather than all
<p>I've setup a Google map that has several plotted markers, each one when clicked on has a little popup with info within.</p>

<p>I'm using the following code to show the company name per plotted marker, but it's going through the foreach loop and showing <strong>ALL</strong> the company names within one popup.</p>

<p>How can loop through and show one company name per plotted marker? I need it to show the first company in the list on the first marker, the second company in the list on the second marker and so on.</p>

<pre><code>// Setting the content of the InfoWindow
infowindow.setContent('
        &lt;?php $pages = get_pages(array('child_of' =&gt; $post-&gt;ID, 'sort_column' =&gt; 'menu_order')); foreach($pages as $post) { 
        setup_postdata($post); 
        $fields = get_fields(); ?&gt;

        &lt;p&gt;&lt;?php echo $fields-&gt;company_name; ?&gt;&lt;/p&gt; 

        &lt;?php } wp_reset_query(); ?&gt;
');
</code></pre>
