Previous/Next buttons for PHP array chunks

95 views Asked by At

I'm trying to create some next/previous buttons for a form that uses an external XML array. I've split the array into chunks with the plan to navigate between each chunk with the next/previous buttons. I've managed to get it working (sort of) whereby I have corresponding next and previous buttons for each chunk, but I obviously only need one of each button on screen. I fear I may have gone about it the wrong way... Is this perhaps a better job for javascript than php?

Also had a look at this stack question but I can't get any of those solutions working with the array chunks... Any insight is much appreciated.

Many thanks

     <?php
       $xml=simplexml_load_file("../scSHARE/editor.xml");
       $xml_array = (array) $xml;
       $chunks=array_chunk($xml_array["Slot"], 4);
       $i=1;

       foreach($chunks as $bank){ 
     ?>
     <div id="bank_menu" class="menu-item menu-item-<?php echo $i;?>" data-target=".bank_<?php echo $i; ?>">
       <a href="">Next</a>
       <a href="">Prev</a>
     </div>
     <?php $i++;}?>
0

There are 0 answers