Problems comparing data and traversing an array

0

Hello good afternoon I have a problem with an array where I bring some .wav files.

This is my code that I have so far where I check that if the name of the file I have in the Database matches the name of the file I have in the array to later put that recording in a player.

<tbody>

  <?php if( !empty($calls) ) {
  foreach($calls as $row){?>
       <tr>
          <td><?php echo $row->calldate;?></td>
          <td><?php echo $row->src;?></td>
          <td><?php echo $row->dst;?></td>
          <td><?php echo $row->billsec;?></td>
          <td><?php echo $row->disposition;?></td>
          <td>
              <?php
  print_r($archivos);

  $archivo = "";

  $tiempo = $row->calldate;
  $tiempo1 = explode("-", $tiempo);
  $tiempo2 = explode(":", $tiempo1[2]);
  $tiempo3 = explode(" ", $tiempo1[0].$tiempo1[1].$tiempo2[0].$tiempo2[1].$tiempo2[2]);

  $fecha1 = $tiempo3[0]."-".$tiempo3[1];

  foreach ($archivos as $file) {
    $extension = substr($file, -3);
    if ($extension == 'wav') {
      $archivo_listo = substr($file, -19, -4);
      if ($archivo_listo == $fecha1) {
        $archivo = $file;
        echo($archivo);
      }

    }

  }
  ?>
  <audio controls>
    <source src="<?= base_url()?>grabaciones/<?php echo($archivo);?>" type="audio/wav">
    <source src="<?= base_url()?>grabaciones/<?php echo($archivo);?>" type="audio/mpeg">
  Your browser does not support the audio element.
  </audio>
</td>

    <td>
            <a type="button" class="btn btn-primary" href="<?= base_url('grabaciones/'.$archivo);?>">
               <i class="fa fa-download"></i> Descargar
            </a>
          </td>
        </tr>
  <?php }
}?>
</tbody>

What is happening is that I take the first name of the Database and check that it exists in the array if it exists, I show it in my player but it only puts it with the first record of it and since there are several it does not pull me anymore the other audios.

Do you know why once you find the first record it does not go through the array anymore?

    
asked by Javier fr 06.09.2018 в 19:28
source

0 answers