I am working on a script and want to use an array called $states twice. $states is an array with a list of 50 states.
I am using the code snippet below to display the results. If I only use the div with class="table-responsive" by itself it works and displays correctly. If I only use the div with class="container" by itself it also displays the results correctly.
However, when I try using both together i.e. one following the other the first one works and the second one displays nothing or at most displays the last result in the array. I have tried resetting array but nothing seems to work.
What am I doing wrong? Any help would be appreciated. Thanks.
<div class="table-responsive" id="defaultview">
<table class="table" width="100%" border="0" cellspacing="0" cellpadding="0">
<? array_shift($states);
$rows3 = array_chunk($states, 2);
foreach ($rows3 as $states) { ?>
<tr>
<? foreach($states as $state){ ?>
<td><a href="/search.php?state=<?=$state['state']?>" title="<?=$state['state']?>">
<?=$state['state']?>
</a></td>
<? } ?>
</tr>
<? }?>
</table>
</div><!-- /End #state -->
<div class="container" id="smallview" style="padding-left: 1px;">
<ul class="list-group">
<?
reset($states);
array_shift($states);
foreach($states as $state)
{ ?>
<li class="list-group-item"><a href="/search.php?state=<?=$state['state']?>" title="<?=$state['state']?>">
<?=$state['state']?>
</a></li>
<? } ?>
</ul>
</div><!-- /End #state -->
unset($states);.reset()? php.net/manual/en/function.reset.php - surely the answer's not actually in the title of the question?