Advertisement
obernardovieira

Read the first 4 words (no. of space not imprtant)

Nov 6th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.27 KB | None | 0 0
  1. //Read the first 4 words of string independently the number os space between her
  2.  
  3. $frase = "<pre>My     longest   text to test in my school that is very close to my village</pre>";
  4. preg_match('/My\s+\w+\s+\w+\s+\w+/', $frase, $result);
  5. print "<pre>".$result[0]."</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement