Re: preg_match
| From: | Michael Temeschinko | Date: | Sun, 03 Aug 2003 06:22:34 +0000 |
| Subject: | Re: preg_match | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158069@lists.php.net to get a copy of this message | ||
Lee Doolan wrote:
Hi Lee, additionaly I have switched the warnings on: Gersten-Grütze²*, Gerstenmehl²*, Haferflocken*, Gemüse 12 % (Lauch*, Möhren*, Zwiebeln*), Haferkleie*, Steinsalz, Petersilie*, Kartoffelstärke*, Hefeextrakt, Sellerieblatt*, Kurkuma*, Muskatnuß*, Pfeffer*, Liebstöckl*) -->>Gersten-Grütze²* Zutat Gersten-Grütze FussnotenID 2 kbA 1 matches matches...array(1) { [0]=> string(14) "Gersten-Grütze" } -->> Gerstenmehl²* Notice: Undefined offset: 0 in /home/mt/amorebio/dem1.php on line 30 Zutat FussnotenID 2 kbA 1 matches matches...array(0) { } -->> Haferflocken* Notice: Undefined offset: 0 in /home/mt/amorebio/dem1.php on line 30 Zutat FussnotenID kbA 1 matches matches...array(0) { } .... and so on why does he matches only the first time ?? Greetings from Germany Micha"Michael" == Michael Temeschinko <mt@amorebio.de> writes:Michael> Hello, Michael> I would like to split a String containing ingredience with additional Michael> assigned footnotes...Michael> my problem I only get the first ingredience ($zutat at line 32 has Michael> only one times the awaited value) but the print on line 29 shows me Michael> that the value of $zutat is right at this point.Michael> what's wrong ????Michael> 1 <?php Michael> 2 Michael> 3 $products_ingredience = 'Gersten-Grütze²*, Gerstenmehl²*, Michael> Haferflocken*, Gemüse 12 % (Lauch*, Möhren*, Zwiebeln*), Haferkleie*, Michael> Steinsalz, Petersilie*, Kartoffelstärke*, Hefeextrakt, Sellerieblatt*, Michael> Kurkuma*, Muskatnuß*, Pfeffer*, Liebstöckl*'; Michael> 4 Michael> 5 ArtikelZutaten ($products_ingredience); Michael> 6 Michael> 7 Michael> 8 function ArtikelZutaten($products_ingredience) { Michael> 9 Michael> 10 Michael> 11 print "\n\n\n$products_ingredience)"; Michael> 12 $Zutaten = explode(",", $products_ingredience); Michael> 13 Michael> 14 foreach ($Zutaten as $zutat) { Michael> 15 if (preg_match("/\²/", $zutat)) Michael> 16 $FussnoteID = 2; Michael> 17 else Michael> 18 $FussnoteID = ''; Michael> 19 Michael> 20 if (preg_match("/¹/", $zutat)) Michael> 21 $FussnoteID = 1; Michael> 22 Michael> 23 if (preg_match("/\*/", $zutat)) Michael> 24 $kbA = 1; Michael> 25 else Michael> 26 $kbA = 0; Michael> 27 Michael> 28 preg_match("/\b.*\b/", $zutat, $matches); Michael> 29 print "\n-->>$zutat"; Michael> 30 $zutat = $matches[0]; Michael> 31 Michael> 32 print "\nZutat $zutat FussnotenID $FussnoteID kbA $kbA"; Michael> 33 Michael> 34 } Michael> 35 Michael> 36 } Michael> 37 Michael> 38 ?>what do you get if youprint "\nmatches matches..."; var_dump($matches);right after line 32?