vendredi 1 janvier 2016

How to detect all the text which has an @ sign in a paragraph in php

In my current php project, I'm sending some special texts attached with an @ sign in a paragraph to the back end. I need to detect all the words which has an @ sign and take them as an array. I was trying with the following regex, but its not working, can anyone help me to fix this

$text = "my text has some @signs and @names";    
preg_match_all('/(?<!\w)@\w+/', $text, $matches);
print_r($matches);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire