How to pass array to javascript function in php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rupalee
    New Member
    • Dec 2010
    • 14

    How to pass array to javascript function in php?

    Code:
     if($uploadval['upload_type']==0)
    						{
    							$url		=	'diacomviewer.php';		
    							print '<a style="cursor:pointer ;font-size:11px; font-weight:lighter; font-family:Arial;"   onclick="popitup(\'' .$url. '\',\'' .$uploadimg. '\',\''.$file_name.'\',\''.$count.'\',\''.$images[].'\')"  >View</a>';
    						}
    				else if($uploadval['upload_type']==2)
    						{
    							print '<span  style="cursor:pointer ;font-size:11px;font-weight:lighter;width:25px; font-family:Arial;"  onclick="showme(\'' .$upload_type. '\',\'' .$uploadimg. '\',\''.$file_name.'\')" >Play</span>';
    						}
    In this code on popitup function i wanna pass php array to javascript function?

    Please Help!!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what kind of PHP array, numeric or associative?

    Comment

    • rupalee
      New Member
      • Dec 2010
      • 14

      #3
      associative array...
      which are having contents as image name

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        be aware that this does not translate into an JavaScript array (but an Object) since JavaScript does not know associative arrays. probably the easiest way in using json_encode().

        Comment

        • rupalee
          New Member
          • Dec 2010
          • 14

          #5
          ok..Thanks

          I will try this..

          Regards,
          Rupalee

          Comment

          Working...