Page 1 of 1

changing word ouput in php

Posted: Sat Oct 15, 2005 12:34 pm
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

Posted: Sat Oct 15, 2005 1:19 pm
by someberry

Code: Select all

count(explode(" ", $words));

Posted: Sat Oct 15, 2005 1:26 pm
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()

Posted: Sat Oct 15, 2005 2:21 pm
by birdie
thanks :)