-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled-1
52 lines (36 loc) · 1.21 KB
/
Untitled-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
function get_title($url){
$str = file_get_contents($url);
if(strlen($str)>0){
$str = trim(preg_replace('/\s+/', ' ', $str)); // supports line breaks inside <title>
preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title); // ignore case
return $title[1];
}
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url_path = parse_url($url, PHP_URL_PATH);
$url_host = parse_url($url, PHP_URL_HOST);
$url_query = parse_url($url, PHP_URL_QUERY);
$path_arr = explode("/",$url_path);
//print_r($path_arr);
?>
<?php
// echo $url_path;
// print_r($path_arr);
//Example:
//echo get_title("http://www.washingtontimes.com/");
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.php">DM Tools</a></li>
<?php foreach ($path_arr as $path) {
if (!empty($path) and $path != "index.php"): {
$current_url = $url_host . "/" . $path
?>
<?php echo $current_url;
echo '<li class="breadcrumb-item"><a>' . get_title($current_url) . '</a></li>';
}
endif;
} ?>
</ol>
</nav>