fork download
  1. <?php
  2.  
  3. $todo = 'Eu irei amanhã à casa. E tu vens?';
  4. preg_match_all('~\w+|[^\s\w]+~u', $todo, $partes );
  5.  
  6. print_r( $partes[0] );
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Eu
    [1] => irei
    [2] => amanhã
    [3] => à
    [4] => casa
    [5] => .
    [6] => E
    [7] => tu
    [8] => vens
    [9] => ?
)