Ok ive done it
took alot of hard work (about 2hoursish) and here it is (it is a function btw)
create a php file called
function.php
Code:
<?php
function gettitle($fileget, $start, $end){
$lines = file($fileget);
foreach ($lines as $line_num => $line) {
$val = htmlspecialchars($line);
$subject .= $val;
}
//Searches for first item set ie. gettitle(file, '{_', '_}'); would look for {_;
$pattern = '%' . $start . '%';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
//Searches for last item set ie. gettitle(file, '{_', '_}'); would look for _};
$pattern = '%' . $end. '%';
preg_match($pattern, substr($subject,3), $matches2, PREG_OFFSET_CAPTURE);
//The numbers are offset due to the 3 in substr (dont delete that 3!) this bit sorts it out.
$val1 = $matches[0][1];
$val1 = $val1 + 5;
$val2 = $matches2[0][1];
$val2 = $val2 + 3;
$val3 = $val2 - $val1;
//End of number offset fix
$final = substr($subject, $val1 , $val3); //Get the value between the two numbers found for the start and end
return $final; //Sets the outcome to script
}
?>
right there is the function made, now how to use it.
here is a test page i created:
Code:
<?php
require_once('function.php');
$title = gettitle('MJMClocks.htm', '{_', '_}');
echo "<html>
<head>
<title>". $title ."</title>
</head>
<body>
Test page for the title | $title
</body>
</html>
";
?>
At the top of the page you must
require_once('function.php');
so it loads up the file with the function in.
This bit gets the title using the function created
$title = gettitle('MJMClocks.htm', '{_', '_}');
the values you need to put in are as follows:
$title = gettitle('FILE NAME', 'START OF STRING', 'END OF STRING');
so in
$title = gettitle('MJMClocks.htm', '{_', '_}');
i am looking for {_TESTTITLE_} in MJMClocks.htm