note 55255 added to function.file

From: Date: Thu, 28 Jul 2005 15:11:41 +0000
Subject: note 55255 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-92651@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55255 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55255&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55255&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92651) next »