Sorry about that but this is my first question on Stackoverflow.
I am trying to retrieve text from multiple .txt files and get their contents on a PHP file. The following code works properly:
<html>
<head>
<title>
</title>
</head>
<body>
<?php
foreach (glob("*.txt") as $filename) {
echo "<br> $filename size " . filesize($filename) . "\n";
$contents = htmlentities(file_get_contents( $filename ));
echo $contents;
}
?>
</body>
</html>
I would like to retrieve everything between the tags on my text files (let's call that step A) and then count the occurrences of every similar item between the span files
I tried solution(s) like the one:
I think that was a similar case: Link here
preg_match_all("/<span>(.+?)<\/span>/is", $str, $matches);
An example of my text file follows:
<span>Wolf</span>Hey guys how are rawr
<span>Harry</span><img src='smiles/heart.png'/>
<span>Harry</span>My heart belongs to Conny
<span>Conny</span>Awww cute!
<span>Xander</span>Grow up Conny…
<span>Zoro</span>I will chase you!
My output would like to be similar to:
$U ($U Being anything between the tags. In this case the name of a user eg. Harry), wrote $X ($X being the number of messages, from my example above for Harry being 2 messages) messages