By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,440 Members | 1,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,440 IT Pros & Developers. It's quick & easy.

seperating by words

P: 22
hello.. please anyone can help me.. i have here a simple problem.. i have a textbox, i'll put any senteces in textbox.. for example, i'll put this "Hi my name is Ehcy" and the output will be like this...

output:
Hi
my
name
is
Ehcy..

how can i do this please help.. thank everyone..
Dec 28 '07 #1
Share this Question
Share on Google+
1 Reply


Markus
Expert 5K+
P: 6,050
Use explode()

[php]
<?php
$string = "hello world how are you?"; //string
$string = explode(' ', $string); //explode the string at spaces - into array
for($i = 0; $i < count($string); $i++){ // i = 0, while i is less than amount of pieces in array, increment i
echo $string[$i]."<br />"; // echo string array seperated by break tag
}
?>
[/php]
Dec 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.