# [web] Can any one mod this?

This topic is 4173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

can any one mod this so it says the files header not the files name its self?
<?php

##### Share on other sites
this is what I could hammer out very quickly.

<?phpif ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") {$ext = substr($file, strpos($file, ".")+1);           if ($ext == "html"){$fh = fopen($file, 'r') or die("Can't open file");$contents = fread($fh, filesize($file));            $offset = strpos($contents, "<TITLE>");                        if ($offset != false) {$offset2 = strpos($contents, "</TITLE>");$len = $offset2 -$offset - 7;              $title = substr($contents, $offset+7,$len);              echo $title; }$contents = "";           fclose($fh); } } } closedir($handle);}?>

##### Share on other sites
I don't understand why you want to do what you're trying to do.

Here is what I do when making php sites, and I'm sure many others do it this way.

I don't know if you're familiar with include statements, but basically you write a file of some code that is shared by all pages in your site. For example, a header and a footer. They would have links to navigate around the page and such.

So you make a header that somewhere in it says:
<title><? echo $title ?></title> Then in every page that is going to use that header, you put in something like: <?$title="Home";include "header.php";?>

You can use \$title anywhere and that's the title... Again I don't know exactly why you want to do what you want to do, but I feel like this might be something that you should think about doing.

##### Share on other sites
Quote:
 Original post by lordcormcan some one just reply with the code?

Do you want to learn how it's done, or do just need someone to do all your work?
Anyway, ntg1976 was already kind enough to do it for you.
When extracting the text between the title tags, you can also consider using regular expressions in PHP. In general, it's a little slower for these simple searches, but it might be useful if whatever you're making should be extended to extract more than just the title.

##### Share on other sites
I had enough of this. Lordcom, we're here to help if you're stuck doing things yourself. If you need someone to do all the work for you, go to Help Wanted. Or go learn PHP yourself. It's easy and the manual is great to learn from as well.