• home
  • forum
  • my
  • kt
  • download
  • Assign PHP Array to Javascript Array

    Author: 2009-03-09 10:55:20 From:

    This little code shows you how to assign PHP array to javascript array

    <?
    	$a[]="one";
    	$a[]="two";
    	$a[]="three";
    	$a[]="four";			
    ?>
    <html>
    <head>
    <title>Assign PHP Array to Javascript Array</title>
    <script language="javascript">
    	function showValues(){
    		var a=new Array;
    	<?
    		for($i=0;$i<count($a); $i++){
    			echo "a[$i]='".$a[$i]."';\n";
    		}			
    	?>
    		for(i=0;i<a.length;i++)
    			alert(a[i]);
    	}
    </script>
    </head>
     
    <body onload="showValues()">
    </body>
    </html>

    discuss this topic to forum

    relation tutorial

    No information

    Category

      Ad Management (6)
      Calendars (3)
      Chat Systems (8)
      Content Management (41)
      Cookies and Sessions (12)
      Counters (15)
      Database Related (34)
      Date and Time (15)
      Development (22)
      Discussion Boards (8)
      E Commerce (8)
      Email Systems (14)
      Error Handling (8)
      File Manipulation (36)
      Flash and PHP (6)
      Form Processing (22)
      Guestbooks (12)
      Image Manipulation (26)
      Installing PHP (7)
      Introduction to PHP (29)
      Link Indexing (8)
      Mailing List Management (9)
      Miscellaneous (56)
      Networking (8)
      News Publishing (9)
      OOP (24)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (6)
      Postcards (1)
      Randomizing (14)
      Redirection (11)
      Searching (9)
      Security (29)
      Site Navigation (16)
      User Authentication (14)
      WAP and WML (7)
      Web Fetching (8)
      Web Traffic Analysis (15)
      XML and PHP (16)

    New

    Hot