Re: preg_match
| From: | Lee Doolan | Date: | Sun, 03 Aug 2003 01:15:12 +0000 |
| Subject: | Re: preg_match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158064@lists.php.net to get a copy of this message | ||
>>>>> "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 you
print "\nmatches matches..."; var_dump($matches);
right after line 32?
--
no toll on the internet; there are paths of many kinds;
whoever passes this portal will travel freely in the world