Hi guys, I am trying to parse a recipes database so it's more organized, into two sections, DIRECTIONS and INGREDIENTS.
But the database that I have to work with puts both the directions and the ingredients into the same field.
here is an example:
<h1>Brie Kisses</h1>
<p>Makes 32.</p>
<p>
1/2 to 2/3 pounds brie cheese (wedges are fine)
<br>1 (17.3 ounce) box frozen puff pastry
<br>Hot pepper jelly
</p>
<p>Cut the brie into 1/2-inch squares (leave the rind on if you like). Place on a dinner plate and put the cheese in the freezer while you thaw the puff pastry for 30 minutes at room temperature.</p>
<p>Unfold the thawed pastry, press together seams and roll lightly with a rolling pin to smooth it out. Cut each sheet into fourths, then cut each fourth in half. Cut the halves in half to make 16 squares per sheet.</p>
<p>Lightly spray a mini-muffin pan with nonstick spray. Fit a piece of dough into each cup, pushing into the cup but leaving the edges sticking up. Place a dab of pepper jelly in each cup, then top with a piece of cheese.</p>
<p>Bake at 400 degrees F for 10 to 15 minutes, until golden. Serve warm. (Can be prepared ahead and refrigerated until ready to bake, or you can bake them and re-warm about 10 minutes at 350 degrees F before serving.)</p>
So this i could probably deal with, but then it gets more complicated, here's an example of the next recipe in the database:
<h1>Sugar and Nut-Glazed Brie</h1>
<p>Posted by Becky/Colo at recipegoldmine.com 12/17/2001 10:16 am </p>
<p>This was my appetizer from last night\'s dinner. Delicious! </p>
<p>Source: Sunset Magazine, January, 2001</p>
<p>Serves/Yields 6 to 8 appetizer servings </p>
<p>2 tablespoons firmly packed brown sugar
<br>2 tablespoons coarsely chopped pecans or almonds
<br>1 1/2 teaspoons brandy, (or other liqueur - I used Kahlua)
<br>1 firm-ripe whole brie cheese (8 ounce)
<br>Crackers
<br>Apple and pear slices
</p>
<p>Stir together the brown sugar, chopped pecans and brandy. </p><p>Place cheese in a baking dish just slightly larger than the width of the cheese. Bake in a 425 degree F oven just until cheese begins to soften in the center, about 6 minutes. </p><p>Evenly sprinkle sugar mixture over cheese. Bake until sugar melts and cheese is melted in center (cut to test), 3 to 5 minutes longer. Scoop hot cheese onto crackers and apple/pear slices to eat.</p>
So you can see the format gets thrown here and a bit and becomes less consistent. Next, it gets even more convoluted, with a multi-header entry...
<h1>Tequila-Cranberry Chutney on Brie</h1>
<p>
<u>Chutney</u>
<br>2 teaspoons vegetable oil
<br>1 cup diced red onion
<br>2 cups fresh or frozen cranberries
<br>3/4 cup diced red Delicious apples
<br>3/4 cup granulated sugar
<br>1/4 cup hot pepper jelly
<br>2 tablespoons tequila
<br>1 tablespoon orange-flavored liqueur
<br>1 tablespoon grated orange peel
</p>
<p>
<u>Brie</u>
<br>1 tablespoon butter or margarine <br>1 cup chopped pecans, toasted
<br>1 small wheel or small wedges brie cheese<br>French bread, sliced and toasted, or melba rounds
</p>
<p>To make chutney: Heat oil in large saucepan over medium heat; add onion and cook 7 minutes. Stir in onion, cranberries, apples, sugar, pepper jelly, tequila, orange liqueur and orange peel; bring to a boil. Reduce heat and simmer, stirring occasionally, 20 to 25 minutes or until thick. Cool.</p>
<p>To prepare brie: Heat butter in a skillet over medium heat. Add pecans and dash of salt; cook, stirring constantly, 1 minute. Place brie on a microwave-safe platter and microwave on high for 45 seconds, or just until warm. Top with chutney, then pecans.</p>
<p>Serve with toast or melba rounds.</p>
<p>Makes 30 servings.</p>
So basically,
ALL that I need to be able to do here, is split the INGREDIENTS and the DIRECTIONS into two separate variables so that I can output them under their own header/section...
Usually I would look to grab sections of text between consistent tags, but in this case, all I have to work with for tags are line breaks and paragraphs.
Note, I added the line break myself so it was easier to read.
here is an actual example from the MYSQL dump
INSERT INTO recipes VALUES ('7', 'spirited apricot brie', 'spirited apricot brie recipe | brie recipes | appetizer recipes', '<h1>Spirited Apricot Brie</h1><p>From the kitchen of Judy Wilson - Arizona</p><p>1/2 cup apricot jam<br>1 tablespoon grated orange peel<br>1 tablespoon brandy or orange juice<br>1 tablespoon lemon juice<br>1/8 teaspoon ground cinnamon<br>1 piece brie cheese (about 1/2 pound)<br>Thin baguette slices or water crackers</p><p>Mix jam, orange peel, brandy, lemon juice and cinnamon in a shallow microwave-safe serving dish just large enough to also hold the brie.</p><p>Set brie in apricot sauce. Return to microwave oven and cook, uncovered, until the cheese is hot and slightly melted, about 1 minute; check at 20-second intervals.</p><p>Scoop cheese and apricot sauce onto the baguette slices.</p><p>Makes 6 appetizer servings.</p>', 'appetizers', 'brie', null, null);
Anyway, this might be impossible... but thought I'd throw it up here and see what the best PHP minds think,
thanks!