I have the following variable $text
which fires out a load of HTML. Most of which is not useful to me for my purposes but some if it is.
HTML that comes out:
<div class="feed-item-description">
<ul>
<li><strong>Impact:</strong> Low</li>
<li><strong>Severity:</strong> <span class="label label-info">Low</span></li>
</ul>
...
What I'd like to do
I'd like to get the impact
and the severity
rating out of this text. I don't need the label.
I have tried doing this:
$itemAttributes = explode (':' , $text);
$impact = $itemAttributes[3];
$severity = $itemAttributes[4];
This does indeed seem to give me the attributes I want, but it also seems to call the word afterwards. It also behaves strangely in that even if I trim it, I cannot get rid of the preceding space from my output.
It also seems to close a <div>
behind it, which I can't explain. I'm sure I'm about to get shouted down about using Regex for HTML, but I figured there must be a way to get something so simple out as it's the same words each time preceding the information I want.
If you want to see the actual output on a page you can see it here: https://dev.joomlalondon.co.uk/ you can see in the output I generate that it closes the <div class="feed-item-description">
but I don't tell it to do that anywhere, and the output I use is contained within an <li>
not a <div>
.