-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
25 lines (21 loc) · 848 Bytes
/
index.php
File metadata and controls
25 lines (21 loc) · 848 Bytes
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
<?php
$source = file_get_contents('https://www.imdb.com/title/tt4154796/');
/* Menggunakan fungsi getStringBetween */
function getStringBetween($string, $start, $end) {
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$judul = getStringBetween($source, 'name="title" content="', ' - IMDb');
$deskripsi = getStringBetween($source, 'name="description" content="', '" />');
/* Menggunakan Regular Expression */
preg_match('/name="title" content="(.*?) - IMDb/', $source, $matches1);
preg_match('/name="description" content="(.*?)" \/>/', $source, $matches2);
$judul = $matches1[1];
$deskripsi = $matches2[1];
echo "Judul: $judul<br>";
echo "Deskripsi: $deskripsi";
?>