How do I change a PHP array into a javascript one?

Discussion in 'PHP' started by Imozeb, Apr 11, 2010.

  1. #1
    I have a php array like:

    PHP Array:
    $myarray[1]['title'] 
    $myarray[1]['pass']
    $myarray[2]['title']
    $myarray[2][pass]
    
    Code (markup):
    and I want to change it to a javascript array like:

    Javascript Array:
    myarray[1]['title'] 
    myarray[1]['pass']
    myarray[2]['title']
    myarray[2][pass]
    
    
    Code (markup):
    How would I do this? (I need a function to change the PHP array into a Javascript one because the values are dynamic)

    Thanks!

    ~imozeb :)
     
    Imozeb, Apr 11, 2010 IP
  2. JREAM

    JREAM Member

    Messages:
    160
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #2
    JREAM, Apr 11, 2010 IP
  3. zerophean

    zerophean Peon

    Messages:
    91
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try using serialize()
     
    zerophean, Apr 12, 2010 IP