I'm trying to match html tag name along with it's attributes. In the example below, I am trying to match div
, class
, style
and id
.
$html='<div class="nav" style="float:left;" id="navigation">';
preg_match_all("/(([^<]\w+\s)|(\S+)=)/", $html, $match);
This returns the array like below.
As you can see, the correct results are kept in Array[2] and Array [3]. I was wondering if it is possible to put the results in a single array, perhaps in Array[1]? Not sure how to do this.
Array
(
[0] => Array
(
[0] => div
[1] => class=
[2] => style=
[3] => id=
)
[1] => Array
(
[0] => div
[1] => class=
[2] => style=
[3] => id=
)
[2] => Array
(
[0] => div
[1] =>
[2] =>
[3] =>
)
[3] => Array
(
[0] =>
[1] => class
[2] => style
[3] => id
)
)