We have variable $menu with HTML inside (there is no loop, it comes from a function).
On echo it gives the code like this:
<ul id="menu">
<li id="some-id" class="many classes one"><a href="#">text</a></li>
<li id="some-id" class="many classes second active"><a href="#">text</a></li>
<li id="some-id" class="many classes three"><a href="#">text</a></li>
</ul>
What I want to do:
-
get value of the
class=""of each<li>. -
if active exists in this value, then go to 3) step.
-
search for one, two, three, four, five inside value. If one of them exists, then throw its name to php variable.
Variable $menu should give:
$name = 'two';
What is the solution?
1 Answer