3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $text = "ert @param trtgg hovno @test etse et e ets @michal @hola michale"; preg_match_all("/((@[\w]+)(\s+([^@]+))?)/", $text, $matches); var_dump($matches);;
based on KXDKR
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
array(5) { [0]=> array(4) { [0]=> string(19) "@param trtgg hovno " [1]=> string(20) "@test etse et e ets " [2]=> string(9) "@michal " [3]=> string(13) "@hola michale" } [1]=> array(4) { [0]=> string(19) "@param trtgg hovno " [1]=> string(20) "@test etse et e ets " [2]=> string(9) "@michal " [3]=> string(13) "@hola michale" } [2]=> array(4) { [0]=> string(6) "@param" [1]=> string(5) "@test" [2]=> string(7) "@michal" [3]=> string(5) "@hola" } [3]=> array(4) { [0]=> string(13) " trtgg hovno " [1]=> string(15) " etse et e ets " [2]=> string(2) " " [3]=> string(8) " michale" } [4]=> array(4) { [0]=> string(12) "trtgg hovno " [1]=> string(14) "etse et e ets " [2]=> string(1) " " [3]=> string(7) "michale" } }