Re: matches problem ("preg_match")

From: Date: Tue, 13 Nov 2001 16:10:49 +0000
Subject: Re: matches problem ("preg_match")
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74460@lists.php.net to get a copy of this message
<? $str="eins zwei drei vier fünf sechs sieben acht neun"; if (preg_match_all("/\w+/", $str, $matches)) { $words = $matches[0]; var_dump($words); } ?> viele Grüße, lallous! "Ewald Schoeller" <info@philosoft.ch> wrote in message news:20011113155013.71958.qmail@pb1.pair.com... > 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 (#74460) next »