matches problem ("preg_match")

From: Date: Tue, 13 Nov 2001 15:53:22 +0000
Subject: matches problem ("preg_match")
Groups: php.general 
Request: Send a blank email to php-general+get-74454@lists.php.net to get a copy of this message
hello we want to save every word of a text in an array field. we want to solve the problem without "split". Here's our code: $str="eins zwei drei vier fünf sechs"; preg_match("'(\w+)(\s+\w+)*'",$str,$Wort); $n=count($Wort); for($i=0;$i<$n;$i++){echo "$i: $Wort[$i]<br>";} The result is: 0: eins zwei drei vier fünf sechs 1: eins 2: sechs it only saves the first and the last word. why doesn't it save every single word in one array field? can anybody give us the (corrected) code to achieve the desired result? thanks for every answer !! Bruno and Ewald

« previous php.general (#74454) next »