Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicate:
Inserting PHP array into Javascript array Inserting PHP array into Javascript array

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

Possible Duplicate:
Inserting PHP array into Javascript array

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

Possible Duplicate:
Inserting PHP array into Javascript array

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

insert duplicate link
Source Link

Possible Duplicate:
Inserting PHP array into Javascript array

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

Possible Duplicate:
Inserting PHP array into Javascript array

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

Post Closed as "exact duplicate" by mplungjan, hakre, PeeHaa, j0k, Graviton
Source Link
Emmi
  • 223
  • 1
  • 2
  • 8

Accessing data stored in Php array in javascript

I'm reading a file in server with php and storing the file content in a variable. now i want to access the variable with javascript, Since I need to split the contents with tab delimited and add the content as options to a Select tag.

 <?php
 //read the 'file' content to lines variable
 $lines = file('file');
 ?>

Javascript to access the PHP variable($lines):

<script type="text/javascript" >
 function readData(){
 var s = '<? echo $lines ?>';
 alert(s);
 }
</script>

Where alert pops up only with Array text

What Should I do so that the data stored in $lines array will be accessed in javascript array variable

default

AltStyle によって変換されたページ (->オリジナル) /