Results 1 to 3 of 3

Thread: convert php Array to javascript array

  1. #1
    Join Date
    Aug 2012

    convert php Array to javascript array

    I have and Array in html

    var Song_list = new Array("Symphony No.1", "Symphony No.2");

    Now I want update the Song_list by the content of Song.txt file

    Song.txt as below
    Symphony No.1
    Symphony No.2
    Symphony No.3
    Symphony No.4
    Symphony No.5

    I use explode() as the follows:

    $f = fopen("Song.txt", "r");
    while (!feof($f)) {
    $arrSong = explode("\n",fgets($f));

    Now I have an array in php and need java code to use this php array to update Song_list = new Array("Symphony No.1", "("Symphony No.1", "Symphony No.2", "Symphony No.3", "Symphony No.4", "Symphony No.5");
    (java code to convert php array to javascript array)

    Or if do not use php function explode, what jave code to import song.txt to updated array Song_list?


  2. #2
    Join Date
    Jun 2006
    Boston, MA
    you should move this under the javascript section. this is not html.
    "Problems cannot be solved by the same level of thinking that created them.

  3. #3
    Join Date
    Jan 2009
    json_encode perhaps?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles