I created an array ("jsArray"), whose entries looks like this:
[41, ["The bird flew into it's cage"]]
[33, ["He drew fire from Joe"]]
[33, ["Roger asked her her name"]]
[2, ["I am awfully happy"]].
I want to pull some words from the
sentence item in some entries.
E.g., in the second entry,
namely, jsArray[1],
do I relate to that sentence
by invoking jsArray[1][1]?
How do I "grab" the whole sentence?
Or some words in the sentence?
How do I make the sentence item
of the entry an array on its own?
Do I push both items separately
to achieve "one array entry"?
Here's my code (with some calculations
replaced by comments to eliminate overload):
Three javascript lines
constitute the entire javascript code.
How do I change these 3 lines:
$item2 = "";
$itemEntry = "[".$item1.",'[".$item2."']]";
print "jsArray.push(\"$itemEntry\" );";
[41, ["The bird flew into it's cage"]]
[33, ["He drew fire from Joe"]]
[33, ["Roger asked her her name"]]
[2, ["I am awfully happy"]].
I want to pull some words from the
sentence item in some entries.
E.g., in the second entry,
namely, jsArray[1],
do I relate to that sentence
by invoking jsArray[1][1]?
How do I "grab" the whole sentence?
Or some words in the sentence?
How do I make the sentence item
of the entry an array on its own?
Do I push both items separately
to achieve "one array entry"?
Here's my code (with some calculations
replaced by comments to eliminate overload):
Code:
<script language="javascript">
jsArray = new Array();
<?php
$file = fopen("./phpArray.txt","r");
$item1 = "";
$item2 = "";
$itemEntry = "";
while(! feof($file))
{
$row = fgets($file);
// Calculate $digits and $length
$item1 = substr($row, $digits, $length);
// Calculate $startat and $len
$item2 = "'".substr($row, $startat, $len)."'";
$itemEntry = "[".$item1.",'[".$item2."']]";
print "jsArray.push(\"$itemEntry\" );";
}
fclose($file);
?>
</script>
constitute the entire javascript code.
How do I change these 3 lines:
$item2 = "";
$itemEntry = "[".$item1.",'[".$item2."']]";
print "jsArray.push(\"$itemEntry\" );";