Jump to content

[SOLVED] Evaluating an html file and a text file to place data into an array


Recommended Posts

Hello all!

 

I received such complete and useful answers to my last two posts that I had to return for another round.  Thanks in advance for your help.  :)

 

I'm working on building an array based on an html file I have, and then will modify the data based on another text file.  This code will be in a class for use with a load of different things for a system I'm working on, but the only part I really am struggling with is this portion.

 

Essentially there's a seven column table with nearly 10,000 rows.  I'd like to match each row to an existing SQL database row, using it's name, to modify the data in the database.  All I need is to learn how to make each row an entry in an array and I can take it from there.

 

The rows have a lot of css/html that I could remove, but it would take ages (and my software always locks up if I try to use a replace all type of command).  It would be preferred if the php would simply recognize the <td> tag  based on the <td portion, find the end of the tag, and know that that's the next column.

 

Here's a shorter example of what I mean:

<tr cssjunk="lots of attributes" moreattributes>
<td lotsofcssjunk="junk!" more="morejunk">First data piece (the name)</td>
<td otherjunk="wow this is getting old">First data piece (the name)</td>
</tr>

I wish to insert each row into an array, with an array of values equal to each columns values (numerical or associative array would both work).

 

It's also useful to note I will be using this on a somewhat regular basis, so I'll be aiming for good error checking and good system feedback to make it easier to do this without much hassle

 

Now to my main questions:

1.  Is there an easy way to evaluate this huge amount of data?

2.  What sort of checks would you recommend I insert?

3.  Is there a way to have the code break the data up and do updates to the page to show the user where the parse is at?

 

This shouldn't be that hard for me, but handling strings of text has never been something I was very good at (I guess this is the point where I change that!)

 

Thank you!

James

I worded this really poorly, didn't I?  Let me try making it a little cleaner:

 

Basically, all I'm trying to do is sort through a really huge html file that uses the above format.

I'd like to take the entries in the HTML files, and get just the text from each row into an array.

Each value of that array would be a single row of the data as an array.

 

How would I go about doing that?

 

Hopefully that makes a little more sense.  :)

 

Thanks again.  :)

This would best be done with regular expressions, I am not a regular expression guru, but I would recommend checking out the regular expressions forum on these boards.

 

Best, Nathan

 

Ha ha... well, I feel silly.  :P

 

Thanks, I guess I've never really used regex for anything, so for some odd reason it never occured to me...  :X

 

Thanks a bunch.  :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.