How can I use the PHP function preg_match_all to match all of the following values in the HTML content in the example and get it in an array?
I need this in an array:
attribute[7]
attribute[823]
multiSelectAttribute[1663]
numericAttribute[1609]
Like this:
$shouldbe = array(attribute[7], attribute[823], multiSelectAttribute[1663], numericAttribute[1609]);
$html = '
<form>
<input type="hidden" name="this_should_not_be_matched" value="" /> <span id=
"syi-attribute-7" class="dropdown required" tabindex="0"><input type="hidden"
name="attribute[7]" value="" /> <span class="label">Test...</span></span>
</form>
<ul class="item-frame">
<li class="item" data-val="">Test...</li>
<li class="item" data-val="30">New</li>
<li class="item" data-val="31">Test2</li>
<li class="item" data-val="32">Test2</li>
</ul><span id="syi-attribute-82" class="dropdown" tabindex="0"><input type="hidden"
name="attribute[823]" value="" /> <span class="label">Test...</span></span>
<ul class="item-frame">
<li class="item" data-val="">Test...</li>
<li class="item" data-val="393">New</li>
<li class="item" data-val="394">New</li>
<li class="item" data-val="395">Test2</li>
</ul>
<div class="ms-opt">
<input id="syi-attribute-8878" type="checkbox" name="multiSelectAttribute[1663]"
value="8878" /> <label for="syi-attribute-8878">Test2</label>
</div>
<div class="ms-opt">
<input id="syi-attribute-8879" type="checkbox" name="multiSelectAttribute[1663]"
value="8879" /> <label for="syi-attribute-8879">Test3</label>
</div>
<form>
<input class="" type="text" name="numericAttribute[1609]" value="" min="0" max=
"99" />
</form>';
I know I can use preg_match_all for it. But in my opinion it's not possible to use multiple "needles" to search through the $html haystack so I'm kinda stuck.