changing word ouput in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

changing word ouput in php

Post by birdie »

ok, this is complicated to explain but the hell with it..
say i've got a script like this..

Code: Select all

<?
$words = $_GET['words'];
echo count($words);
?>
if you are familiar with count(), you should know that you need to array each word. One problem my input script is only like this..

Code: Select all

<form action="script.php" method="GET">
<input type="text" name="words">
<input type="submit" value="submit">
</form>
does anyone know how to solve this problem? thanks alot
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Post by someberry »

Code: Select all

count(explode(" ", $words));
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

what someberry suggested should work. What explode does is that it creates an array, with each element being the text before the delimeter (the first parameter).

explode()
implode()
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

Post by birdie »

thanks :)
Post Reply