note 55255 deleted from function.file by bjori
| From: | bjori@php.net | Date: | Wed, 22 Mar 2006 13:47:38 +0000 |
| Subject: | note 55255 deleted from function.file by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106250@lists.php.net to get a copy of this message | ||
Note Submitter: undejj
----
I created a function to grab the title of a file from another central file that associates filenames
to titles, one per line.
Format of the titles.ini file is:
"filename.ext","This is my title"
"filename2.ext","This is another title"
<?php
function filetitle($file)
{
$lines = file("files/titles.ini");
foreach ($lines as $key => $value) {
if(strpos($value, $file) > 0) {
$s = strpos($value, ",")+2;
$title = substr($value, $s, -2);
break;
} else {
$title = $file;
break;
}
}
return $title;
}
?>
I use this for directory listings where the filenames are not very descriptive.