rmlm 2 Report post Posted March 19, 2011 Boas, Imaginem que tenho o input onde escrevo, por exemplo, "Boa tarde" Como é que eu posso dividir este texto em 2 palavras e armazena-las em duas variaveis, ou seja, ao detectar um espaço em branco separa o texto e guarda... teria $texto = "Boa Tarde"; e depois saia: $palavra1 = "Boa"; $palavra2 = "Tarde"; Obrigado Share this post Link to post Share on other sites
brunoais 65 Report post Posted March 19, 2011 http://www.php.net/manual/en/function.explode.php "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%. Share this post Link to post Share on other sites
rmlm 2 Report post Posted March 19, 2011 Oh categoria! Obrigado bruno pela pronta resposta Share this post Link to post Share on other sites
rmlm 2 Report post Posted March 19, 2011 Mas agora surgiu-me uma duvida, se na frase em vez de um espaço tiverem dois ou mais a funçao já nao trabalha bem... Há alguma maneira de contornar isso? Share this post Link to post Share on other sites
brunoais 65 Report post Posted March 19, 2011 http://www.php.net/manual/en/function.preg-split.php regex: '/[ ]+/' Deve funcionar. "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%. Share this post Link to post Share on other sites
rmlm 2 Report post Posted March 19, 2011 http://www.php.net/manual/en/function.preg-split.php regex: '/[ ]+/' Deve funcionar. Funciona perfeitamente Share this post Link to post Share on other sites