Skip to content

Commit cb8c0c2

Browse files
committed
HTMLHelper
1 parent 75a57f1 commit cb8c0c2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

berry/utils.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
2+
23
require_once(__DIR__ . "/utils/CrawlerDetector.php");
4+
require_once(__DIR__ . "/utils/HTMLHelper.php");
35
?>

berry/utils/HTMLHelper.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
class HTMLHelper
4+
{
5+
6+
public function __construct()
7+
{
8+
9+
}
10+
11+
/**
12+
* Returns an array with HTML objects of the given tag type contained in
13+
* the given html string.
14+
* @param string $tag the tag to search
15+
* @param string $html is the html string to search for tag objects
16+
* @return type array with html objects
17+
*/
18+
public function GetAllTagsFromHTMLString(string $tag, string $html)
19+
{
20+
$imgs = array();
21+
preg_match_all('/<' . $tag . '[^>]+>/i', $html, $result);
22+
for ($i = 0; $i < sizeof($result); $i++)
23+
{
24+
$imgs[$i] = $result[0][$i];
25+
}
26+
return $imgs;
27+
}
28+
}
29+
30+
?>

0 commit comments

Comments
 (0)