これをFirefoxでテストしたところ、正常に動作しましたが、配列の最後の部分にコンマがあるため、IEでは動作しませんでした。PHPを使用してコンマを削除するにはどうすればよいですか?
実結果:
{image : 'folder/pic1.jpg', title : '', thumb : 'folder/pic1.jpg', url : ''},
{image : 'folder/pic2.jpg', title : '', thumb : 'folder/pic2.jpg', url : ''},
{image : 'folder/pic3.jpg', title : '', thumb : 'folder/pic3.jpg', url : ''},
期待される結果:
{image : 'folder/pic1.jpg', title : '', thumb : 'folder/pic1.jpg', url : ''},
{image : 'folder/pic2.jpg', title : '', thumb : 'folder/pic2.jpg', url : ''},
{image : 'folder/pic3.jpg', title : '', thumb : 'folder/pic3.jpg', url : ''}
コード:
<?php
$directory = "pic/";
$images = glob("".$directory."{*.jpg,*.JPG,*.PNG,*.png}", GLOB_BRACE);
if ($images != false)
{
?>
<script type="text/javascript">
jQuery(function($){
$.supersized({
slideshow: 1,//Slideshow on/off
autoplay: 1,//Slideshow starts playing automatically
start_slide: 1,//Start slide (0 is random)
stop_loop: 0,
slides: [// Slideshow Images
<?php
foreach( $images as $key => $value){
echo "{image : '$value', title : '', thumb : '$value', url : ''},";
}
?>
],
progress_bar: 1,// Timer for each slide
mouse_scrub: 0
</script>
<?php
}
?>