从php到javascript获取变量

What am I trying to do? To finish my final school year I have to script a code which shows a diashow.

Every slide has their own displaytime, so the variable has to change automatically when the timer hits the value.

These time information are in the variable array[$i]["Anzeigedauer"]

Variable $array[] -> all data from database stored in here

When I try to take this variable in javascript see var ad it outputs output Output as often as there are data in the database

Ps. I am quite new in scripting so if any other informations are required, please let me know

<?php

  while ($dsatz = mysqli_fetch_assoc($query))
    {
      array[] = $dsatz;
      $count = count($array);
    }
    
  
for ($i = 0; $i <= $count-1: $i++)
  {
    echo $array[$i]["Anzeigedauer"];
    $zeit= $array[$i]["Anzeigedauer"];
  
    echo "<li><h1>", $array[$i]["Titel"] . "</h1><br>"
    ."<p id='inhalt'>", $array[$i]["Titel"] . "</p><br></li>";
  }
  
  mysqli_close($con);
  
?>

<script>
  var ad = <?php echo json_encode($array[1]["Anzeigedauer"]);?;
  
  // var sek = "<?php echo $array[$i]["Anzeigedauer"]?>";
  //var mili= sek*1000;
  
  ad.toString(); 
  
  $("#foo3")-carouFredSel({
    items: 1,
    auto: 1000 // need variable here!!!
    scroll: 1,
    pagination : "#foo3_pag"
    });
  </script>

</div>