-1

PHPから配列を取得し、ギャラリー関数にimagearrayを入力するにはどうすればよいですか?

       $leftimages = $images->GetSlideShowImages($userid,$campaignid,$screenid,'midleft');
       var phparray = <?php echo json_encode($leftimages) ?>;
$.each(phparray, function (i, elem) {
           imagesarray.push(elem['image']); 
});



      var mygallery=new gallery({
wrapperid: "temp1_leftshow_f", //ID of main gallery container,
dimensions: [500, 300], 

    imagearray: [
    ["http://myimageurl1.jpg", "", "_new", "text1"],
    ["http://myimageurl2.jpg", "", "_new", "text2"],
    ["http://myimageurl3.jpg", "", "_new", "text3"],
],
4

2 に答える 2

1

javascript配列が形成されているのを確認した時点で、PHPを挿入して値を出力できます。

例えば:

imagearray: [
<?php
    // LOOP AND PRINT
    // e.g. print('["http://myimageurl1.jpg", "", "_new", "text1"],');
?>
于 2013-02-14T14:38:41.550 に答える
0
  $leftimages = $images->GetSlideShowImages($userid,$campaignid,$screenid,'midleft');
   var phparray = <?php echo json_encode($leftimages) ?>;
 $.each(phparray, function (i, elem) {
       imagesarray.push(elem['image']); 
     });



  var mygallery=new gallery({
   wrapperid: "temp1_leftshow_f", //ID of main gallery container,
   dimensions: [500, 300], 

imagearray: [
<? for ($i=1;$i++,$i<4){?>
<?php echo $comma; $comma=",";?>["http://myimageurl<?php echo $i;?>.jpg", "", "_new", "text<?php echo $i;?>"]
 <?php }?>
 ],
于 2013-02-14T14:51:31.773 に答える