titanic_fanatic
12-20-2006, 05:14 PM
I have a script that is currently serving as a course content management system which simply displays all media in a directory in a list of links that look like this index.php?action=showfile&filename=filename.mp3&type=mp3
where type determines wich directory to look for filename.mp3 (audio) and filename is of course the filename.
for this filename.mp3 file, it would also be accompanied by a filename.mp3.dia which is only a text file with spanish text.
I need to read this text file and encode all special characters into html which I have accomplished by using this little bit of code:
function encode_dialogue($file){
$lines = file($file);
foreach ($lines as $key => $value){
$encoded_value = encode_accents($value);
$lines[$key] = $encoded_value;
header("Content-type: text/html");
$dia .= $lines[$key];
}
return $dia;
}
function encode_accents($text){
foreach(get_html_translation_table(HTML_ENTITIES) as $a=>$b){
$text = str_replace($a,$b,$text);
}
return $text;
}
I call the function encode_dialogue() like this:
$myVariable = encode_dialogue($url_to_filename.mp3.dia);
When I call the variable $myVariable in my php generated html page, the text appears except the html codes like:
¡
just display like this and aren't parsing???
any Ideas???
where type determines wich directory to look for filename.mp3 (audio) and filename is of course the filename.
for this filename.mp3 file, it would also be accompanied by a filename.mp3.dia which is only a text file with spanish text.
I need to read this text file and encode all special characters into html which I have accomplished by using this little bit of code:
function encode_dialogue($file){
$lines = file($file);
foreach ($lines as $key => $value){
$encoded_value = encode_accents($value);
$lines[$key] = $encoded_value;
header("Content-type: text/html");
$dia .= $lines[$key];
}
return $dia;
}
function encode_accents($text){
foreach(get_html_translation_table(HTML_ENTITIES) as $a=>$b){
$text = str_replace($a,$b,$text);
}
return $text;
}
I call the function encode_dialogue() like this:
$myVariable = encode_dialogue($url_to_filename.mp3.dia);
When I call the variable $myVariable in my php generated html page, the text appears except the html codes like:
¡
just display like this and aren't parsing???
any Ideas???