PHP $num value changes on page title

Hey all, I’m after a piece of code that changes the $num value based on a page title (or file name if page title cannot be done)

This is the piece of code that I have at present. I need to change the number value based on what page title or filename
[php]<?php

$num = 1;

?>[/php]

I have to admit, apart from guessing that a $get_ function would be called, or an $if option e.g.

[php]function page title()
$if page title =“value” then $num =3; [/php]

Thanks in advance

To do it for title, try this code:
[php]
function get_page_title($url){
if( !($data = file_get_contents($url)) ) return false;
if( preg_match("#(.+)</title>#iU", $data, $t)) {
return trim($t[1]);
} else {
return false;
}
}
[/php]
Obviously it is a function, but you can just use the code instead…

Or, to get the actual filename of the current page:
[php]
$currentFile = $_SERVER[“PHP_SELF”];
$parts = Explode(’/’, $currentFile);
echo $parts[count($parts) - 1];
[/php]

I am sure one of those will do you just fine… good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service