RE: Copying PHP array into a Javascript array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Something along the lines of the following:

<script type="text/javascript">
	var myArray=new Array();
<?php
	$files=getFiles($d);
	foreach ($files as $key=>$val) {			
?>
		myArray[<?php echo $key;?>]="<?php echo $val;?>";
	<?php
	}
?>
</script>
	
Although it looks nasty, I believe it could be a quick hack.

-----Original Message-----
From: Otto Wyss [mailto:otto.wyss@xxxxxxxxxx] 
Sent: Tuesday, April 10, 2007 4:37 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Copying PHP array into a Javascript array

I don't know if I should ask this question here or in the JavaScript 
group. I'll try it here since people usually are more helpful.

I've an array of file names

   $files = getFiles ($d);

but would like to use this array in a JavaScript array. How can I copy 
this $files into a JavaScript variable?

O. Wyss

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux