By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,208 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,208 IT Pros & Developers. It's quick & easy.

how do I import from a PHP array in a Javascriptarray

P: n/a
I cannot figure out how to import an array from PHP into Javascript

MyPHPcode is like this

While ($i < $num) {
$PHPvar= (" $PHPvar \" $Mystring[$i] \" , ");

The ouput of $Mystring is: "string1","string2","etc"," " (the
last empty string is added later on in the function:
This is exactly what Javascript expects in an array, however I get no
output in Javascript this way.
transfering data:

<INPUT TYPE= "hidden" ID= "PHP2JS" VALUE="<?php echo( $c);?> ">


<script type="text/javascript">

var text=PHP2JS.value;

myarray = new Array(text);

for etc.

When I replace the \" with nothing (in the PHP part) it works in
the - document write(text) - and all data is loaded into
myarray(0) but I need the " " .

does someone have a better idea?



Frits v/d Laan
Biologische tuinplanten kwekerij
Feb 4 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a

<script type="text/javascript">
echo "var myjsArr=split(" . implode(",", $Mystring) . ")"; //
$Mystring being the php array object

as for addressing an IDed object in js, you use
Feb 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.