transferring PHP-array to javascript-array
Posted: Tue Feb 03, 2004 7:34 am
Hi,
can anybody tell me how I can transfer a PHP-array to javascript-array?
I tried this:
I also tried to set an $i variable between the script-tags, like this:
but that didn't work eather.
Can anyone please help me???
can anybody tell me how I can transfer a PHP-array to javascript-array?
I tried this:
Code: Select all
<?php
$myarray = array();
$myarrayї1]= "een";
$myarrayї2]= "twee";
$myarrayї3]= "drie";
?>
<SCRIPT LANGUAGE="JavaScript">
for (var i=1;i<= 3;i++)
{
optTestїi] = "<?php echo $myarrayї'i']; ?>";
}
</script>Code: Select all
<?php $i=1; ?>
for (var i=1;i<= 3;i++)
{
optTestїi] = "<?php echo $myarrayї'i']; ?>";
<?php $i++; ?>
}Can anyone please help me???