Here is what I'm trying to achieve,
Read a text file using PHP and assign each line of it to an array value and print them,
<?php
$file = fopen("news.txt", "r");
$news = array();
$count = 0;
while (!feof($file)) {
$count = $count + 1 ;
$news[] = fgets($file);
}
fclose($file);
for ($x=1; $x<$count; $x++){
echo $news[$x];
}
?>
The code is working fine but now I want to create an array in javascript, exactly equal to the size of the number of lines read using php ($count), here is my code for that,
var content=new Array()
for (var i=0;i<<?php echo $count ?>;i++)
This javascript loop will iterate equal number of time as the number of lines in text file.
Since it is clear from the code that each line of text is stored in a variable $news,
How can i assign each line of text from the variable $news to the array of inside the javascript ?
It should be something like this,
var content=new Array()
for (var i=0;i<<?php echo $count ?>;i++){
content[i] = ***$news[i]***
How to assigned each line of text from PHP variable to the each variable of array content[] ?