rmlm 2 Posted March 19, 2011 Report Share 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 Link to post Share on other sites
brunoais 65 Posted March 19, 2011 Report Share 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%. Link to post Share on other sites
rmlm 2 Posted March 19, 2011 Author Report Share Posted March 19, 2011 Oh categoria! Obrigado bruno pela pronta resposta Link to post Share on other sites
rmlm 2 Posted March 19, 2011 Author Report Share 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? Link to post Share on other sites
brunoais 65 Posted March 19, 2011 Report Share 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%. Link to post Share on other sites
rmlm 2 Posted March 19, 2011 Author Report Share Posted March 19, 2011 http://www.php.net/manual/en/function.preg-split.php regex: '/[ ]+/' Deve funcionar. Funciona perfeitamente Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now