Barriestard
03-27-2007, 07:25 PM
Hi, Im stuck parsing a document into lines and then echo'ing them out via a variable to certain lines of html code.
IE:
I have in the header:
<?PHP
$textfile= "comments.txt";
$handle = fopen($textfile, "r");
$contents = fread($handle, filesize($textfile));
fclose($handle);
$array01 = explode("&", $contents);
echo $array01[1];
?>
the txt file "comments" contains (for this example):
&ONE
&TWO
&THREE
.. so far I can simply echo out either line one two or three via the array denoted by "&" .. great. Now I need to set this so I can call this echo in certain places of my html code. The text will be pulled in and placed by choice for ALT (im using overlib) text on mousover. So far I have:
<a href="javascript:sendEvent('playitem',0)" onmouseover="return overlib('<?php echo $array01[1];?>', CAPTION, '(click to listen)', STATUS, 'click to listen', FGCOLOR, '#d8e0e3', BGCOLOR, '#175b7b', BORDER, 3, CAPTIONFONT, 'Verdana', TEXTFONT, 'Verdana', TEXTSIZE, 1, ol_width=400, ol_offsetx=12, ol_offsety=17);" onmouseout="return nd();">
(the rest of the line continues using overlib commands)
this in my very basic PHP mind should show "ONE" in my mouseover, but it just causes a JS error in the browser "unterminated string constant".
I know this is basic .. im new to PHP so I may be causing a red herring.
I simply want a text file or xml than can be parsed, split into lines that I can ID and echo out into the html line you see above so each line of text on mouseover via overlib is the text from the document per line.
I see examples where its echoed out to a table etc but I need it to be called/echoed within my specific html line using a variable, which is where I get stuck.
all help welcomed, example code and description would be great :)
IE:
I have in the header:
<?PHP
$textfile= "comments.txt";
$handle = fopen($textfile, "r");
$contents = fread($handle, filesize($textfile));
fclose($handle);
$array01 = explode("&", $contents);
echo $array01[1];
?>
the txt file "comments" contains (for this example):
&ONE
&TWO
&THREE
.. so far I can simply echo out either line one two or three via the array denoted by "&" .. great. Now I need to set this so I can call this echo in certain places of my html code. The text will be pulled in and placed by choice for ALT (im using overlib) text on mousover. So far I have:
<a href="javascript:sendEvent('playitem',0)" onmouseover="return overlib('<?php echo $array01[1];?>', CAPTION, '(click to listen)', STATUS, 'click to listen', FGCOLOR, '#d8e0e3', BGCOLOR, '#175b7b', BORDER, 3, CAPTIONFONT, 'Verdana', TEXTFONT, 'Verdana', TEXTSIZE, 1, ol_width=400, ol_offsetx=12, ol_offsety=17);" onmouseout="return nd();">
(the rest of the line continues using overlib commands)
this in my very basic PHP mind should show "ONE" in my mouseover, but it just causes a JS error in the browser "unterminated string constant".
I know this is basic .. im new to PHP so I may be causing a red herring.
I simply want a text file or xml than can be parsed, split into lines that I can ID and echo out into the html line you see above so each line of text on mouseover via overlib is the text from the document per line.
I see examples where its echoed out to a table etc but I need it to be called/echoed within my specific html line using a variable, which is where I get stuck.
all help welcomed, example code and description would be great :)