0

I am trying to make my website more manageable by using php to list the meta-titles of pages within a portfolio/ directory as an unordered list of links to those pages. Can anybody help? Here's an example of how I would want it to look as it does in the top of the right sidebar: http://huwdesign.co.uk/portfolio/WaterCrisis.html

Would really appreciate some suggestions! Cheers.

Huwbo
  • 11
  • 3
  • Check these links, they may shed some light on what you want to achieve: http://stackoverflow.com/questions/4348912/get-title-of-website-via-link http://stackoverflow.com/questions/6900144/get-title-from-link-php-simple-html-dom-parser http://php.net/manual/de/function.scandir.php – Funk Forty Niner May 24 '13 at 15:23

1 Answers1

1

We're going to use the glob() function, which returns an array of all the files in a specific directory, and the basename() function which returns the name of a file.

<?php

$dir = 'portfolio'; // The directory containing the files.
$ext = '.html'; // The file extension.

foreach (glob($dir . '/*' . $ext) as $file) {
    echo basename($file, $ext); // Echos out the file name.
}

You'd want to change the value of the $ext variable and the $dir variable. Using the code above, I'm sure you could figure out how to make a list. You can also use file_get_contents() to get the contents of the file if you so desire. :)

Terry Harvey
  • 840
  • 6
  • 12