php pattern player player subject 213123sasds фывыф player1213 asdsda

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php
$pattern = '/(?P<player>@ player[\d]+)/';
$subject = '213123sasds фывыф @ player1213 asdsda фывыфв @ player56';
$matches = array();
if(preg_match_all($pattern, $subject, $matches))
$players = $matches['player'];
else
$players = array();
foreach($players as $player)
echo $player, PHP_EOL;