Jump to content

badaboom55

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

badaboom55's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello All, I have a tab-delimited .TXT file that I'm trying to process and insert into a MySQL database. The file() function will write each row of the text file as a separate element in an array. So, my text file (see attached) is pretty simple and only has 2 rows... the first row contains the column headers, i.e. "Column A, Column B, Column C..." and the second row contains the values. i.e. "Value A, Value B, Value C..." However, I'm running into a problem because several of the columns actually contain multiple values separated by carriage returns (line breaks), and the file() function doesn't seem to like this: -------------- | Column C | -------------- | > Value C1 | | > Value C2 | | > Value C3 | -------------- Here's my code: <?php // Read each row into an array as separate elements $Rows_array = file(MyText.txt); // Output the column headers echo $Rows_array[0]; // ouputs: Column A Column B Column C Column D // Output the values echo $Rows_array[1]; // outputs: Value A Value B "> Value C1 ?> So, it seems like the file() function does what it's supposed to until it gets to the first line break. Also, a doublequote (") appears before the first value in the column with the carriage return, so I'm sure there's some sort of escaping issue. Anyway, is there a way to workaround this or a step I am missing? Note: I tried file_get_contents() as well to try and get the row into a string instead of an array, and it gives the same result. Ultimately, I AM just going to throw out the line breaks and explode() the values in Column C as their own array or string, but I need to get all those values passed to my PHP code first, which is where I'm struggling. And, I really want to avoid "pre-processing" the txt file by opening it in excel or something and removing the carriage returns in the culprit columns. [attachment deleted by admin]
  2. Hello All, I'm a designer who taught myself HTML/PHP/MySQL and some basic web developing. I'm slightly anal and always hated the way the WYSIWYG editors like Dreamweaver layed out the code. So, for years I've just used Notepad and "hand" coded everything. However, the other day I was on a friend's Mac browsing the internet with either Safari or FireFox, and when I went to "View Source", instead of the bland .txt file I'm used to seeing in IE... I got a nice little color-coded display of the code. I do a lot of Flash/ActionScript work, and Flash does the same thing with the ActionScript... color-coding keywords, comments, strings, etc. which is infinitely helpful in proofing/troubleshooting. So, it occured to me that there HAS to be some "code-editing" (not sure of the proper term) software out there that I could use to edit my ".html" files instead of Notepad. So, I wanted to get any suggestions on which software package(s) I should be seeking out? 1) The FREE-er the better 2) I work mostly with HTML/PHP/MySQL with a sprinkling of JavaScript; so it would be nice if the software was able to recognize a variety of programming languages in the same ".html" or ".php" file and color the code accordingly? 3) It would also be nice to do some simple testing of the ".php" file locally, like checking the code syntax to make sure I didn't forget a semi-colon or something. Thanks!
×
×
  • 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.