Im trying to get an array of words in a string using preg_match..WORD1
and WORD2
are variables which can change.
$content= 'class="gametitle WORD1">< ggg class="userid">WORD2 </ gg>';
i want to get WORD1
and WORD2
right now Im only able to get word 1
$prematch=preg_match('/.class="gametitle.(.*)".*/isU', $content, $matches);
echo $matches[1];
thx in advance!
if (preg_match_all('/class\s?=\s?"gametitle\s+(\w+)"><[^>]+>\s?(\w+)/', $text, $matches)){
$word1 = $matches[1][0];
$word2 = $matches[2][0];
}
Or with preg_match
:
if (preg_match('/class\s?=\s?"gametitle\s+(\w+)"><[^>]+>\s?(\w+)/', $text, $matches)){
$word1 = $matches[1];
$word2 = $matches[2];
}