Jump to content

New Line Parsing


Kasuke_Akira

Recommended Posts

If I were to copy and paste some code into a textbox and use PHP to parse it, how would I make sure that each line is recognized as a new entry.

 

I have 6 categories that I will be parsing for, and running the text through a while() loop till it gets each set of information.  So, basically, it will loop through 6 times, putting the appropriate information into the variables, putting those into the mySQL databse, and then starting over with the next 6 lines as a new entry into the databse.  It's just that I need to know how to make sure the PHP only parses one line at a time of the pasted text.

 

This is an example of what exactly will be going into the textbox.  except "CardName:" etc, will be replaced with different text for each set.

<tr><td class="TextResultsRowHeader">CardName:</td>
<tr><td class="TextResultsRowHeader">Cost:</td>
<tr><td class="TextResultsRowHeader">Type:</td>
<tr><td class="TextResultsRowHeader">Pow/Tgh:</td>
<tr><td class="TextResultsRowHeader">Rules Text:</td>
<tr><td class="TextResultsRowHeader">Set/Rarity:</td>
<tr><td> </td><td> </td></tr> //this line will indicate to start over by resetting the counter
<tr><td class="TextResultsRowHeader">CardName:</td>
<tr><td class="TextResultsRowHeader">Cost:</td>
<tr><td class="TextResultsRowHeader">Type:</td>
<tr><td class="TextResultsRowHeader">Pow/Tgh:</td>
<tr><td class="TextResultsRowHeader">Rules Text:</td>
<tr><td class="TextResultsRowHeader">Set/Rarity:</td>
<tr><td> </td><td> </td></tr> //this line will indicate to start over by resetting the counter

Link to comment
https://forums.phpfreaks.com/topic/41015-new-line-parsing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.