Add a php created array into javascript -


I am using a JavaScript slideshow on my index page. Instead of stabilizing the array, I want to create an array with PHP and want to add it in some way and include the statement. Since the array is inside Javascript so I'm sure how best to do this. Here is a sample of the array:

  var fadeimages = new array () fadeimages [0] = ["pics / fade_pic_1.jpg", "", ""] fadeimages [1] = [ "Picture / Feed_pic_2.jpg", "", ""] Fadeimage [2] = ["Pix / Fade_Pix_3.jpg", "", ""]  

And this is the PHP file The array that makes this work great I do not know how to put it in JavaScript code:

   "; $ X ++;}?  

Thanks in advance for any help, you can give me!

You can use it for.

  & lt ;? php //buildfadepic.php $ result = array () ; Foreach (Globe ("pics /*.*") as $ filename) {$ Result [] = Array ("Picture / .file.", "", "");} Print json_encode ($ result);  

This will give you valid JSON (and therefore valid JavaScript). If you want to mix javascript and PHP, you should be able to do it now

  var fadeimages = & php include "buidfadepic.php";? & Gt;; Since buidfadepic.php will give you a result like this  
  [["Pics / foo.jpg", "", ""], ["Pics / bar.png", "", ""], ...]  

or If you have both in the same file, then print / echo comments instead of joining the bus.


Comments