Create a class in PHP that will read HTML documents from a f

Create a class in PHP that will read HTML documents from a file system and count the number of HTML tags within the document.

For example:

<html></html> = total count: 1

<html><head></head><body></body></html> = total count: 3

Solution

<?php
//$str = file_get_contents(\'index.html\'); // this is for a file
$str = \"<html><head></head><body></body></html>\"; // this is for self written tags
$search = preg_match_all(\'/<([^\\/!][a-z1-9]*)/i\',$str,$matches);

echo \"total count: \". sizeof($matches[0]);

?>

Create a class in PHP that will read HTML documents from a file system and count the number of HTML tags within the document. For example: <html></html

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site