Parsing Comma Separated Value (CSV) Files with PHP

Learn PHPI hate trying to parse CSV with PHP. I get PO’d ASAP because everyone should be using TSV instead. I know, it can be as difficult to comprehend all of the acronyms as it is to figure out the comma separated values. Not impossible, just very time consuming.

I have had multiple occasions where someone gives me a file and asks me to parse it. The issue is its in CSV format. CSV Sucks! The problem is when you get someone trying to be cute so they put a comma (,) in one of the records.

So let me back up. CSV started out as a basic format to make data portable. A CSV file is basically a database in a way. Each line in the file represents a record. Each field within the record is delimited by a comma. Or so it is suppose to work. So typical CSV looks like this: Read more

Fire Comcast, Direct TV, or DISH Network!

Are you tired of paying for TV, DVR, PVR, on-demand, TiVo, etc.? So am I! One of my resolutions this year is to find ways to reduce spending. I mean, we are all complaining that the government is spending too much. I should do my part too. So I have been looking for ways to cut costs. While doing my research, I found a way that I can get rid of the TV (in terms of broadcasting expenses) and substitute it with something else. So what is it? Read more

The Shortest “Shorten URL” URL

Wow! Try saying that 5 times real fast. I have been doing a lot of research lately on domains and what makes them valid. I have been reading the RFC documents and searching the Internet for information. It’s amazing what you can find.

With the the proliferation of users on the Internet, domain names are getting longer and longer. It is estimated that all available 3 letter domain names are now taken. From the looks of it, this is only going to get worse. That said, long domain names can be difficult to use. It wouldn’t make sense to put my-new-company-domain-name.com on your business card would it? And certain social networks limit how much space you have. Like twitter only allows posts of 149 characters. If you have a long URL, much of what you want to say will have to be left off just so the link will fit within the 149 character limitation.

This is where “shorten url” websites come in really handy. By far, I would submit that bit.ly is the one I prefer over any other. The reasons are:

  • it’s a shorter domain name than tinyurl.com
  • it tracks traffic on the URLs I shorten

That being said, what if you are looking for the shortest “shorten URL” website possible. Do you know what it is? Well, you heard it here first. Read more

Domain Name Validation Class for PHP

Learn PHPBy the time I finish writing this, there will probably be 10 new domain validation routines uploaded somewhere on the Internet.  The only problem is, the majority of them are incomplete. Incomplete would be the equivalent to wrong, depending on what you are looking for in a validation routine. The problem? Most developers don’t read the requirements / specifications. The majority of developers do not take time to RTFM (read the freaking manual) for anything. What makes you think we will spend time reading the ever so boring RFC documents?

Domain validation is a common issue as evidenced by the more than 42,000,000 results on Google when you search for domain name validation php. But who can you trust to do it right? If I were to ask you what makes a valid domain name, do you know? Do you know how long a domain name can be? Do you even really know what a domain name is? Continue reading, and I bet you will be enlightened. Read more

PHP Phone Validation Class

A few days ago, I wrote a post about validating NANPA regulated phone numbers. So late last night, I figured since I have already done the research and figured out the work, why not build a class and put it online for everyone? So that’s what I did.

During the process, I realized how easy it would be to apply the “optional” filters I discussed in my previous post. I document them on the Google Code wiki where my open source repository is. Read more

Real World Email Requirements From RFCs? NOT!

Two days ago I started out with the intent to completely understand the RFC Documents specifying the requirements for valid email addresses, write the worlds greatest PHP regex to validate email addresses, and then shout it out around the Internet from right here. At the time it sounded like a great idea. So I set out on my quest and started digging up the necessary RFC Documents. I was surprised with what I found. Read more

PHP Regex for Validating Phone Numbers

So, you want to validate a phone number, huh? This is much different than verifying a phone number. To verify a phone number you could simply call the number to see if it connects to someone. But applications and databases don’t necessarily need to verify the number. On most occasions however, the data should be validated so that before a user sees it, they know it has been validated as a “good” number. I define validated as a number that can be assigned based on the North American Numbering Plan (NANPA).

I have seen numerous attempts to validate a phone number using a simple regex but they are all wrong. They best they can do is validate the number of digits. This method and any similar variation is completely useless! Even if you are checking for all the possible delimiters and removing spaces, etc. So how should it be done then, you ask? Easy! Read more

Squeeze Page Marketing on the Internet

What is a squeeze page? Currently there is some debate as to the content of the squeeze page. Some would say there are offers as well as links to other areas of the site. This is what I would consider a landing page designed to get your audience to purchase something. My definition of a squeeze page is a web page that contains content designed to interest the marketers readers enough to sign-up on an opt-in email form. They are designed to get the reader to give up their name and email address in order to get something in return like a free video, ebook, or graphics/templates package. Thus the term “squeeze page”. How can you squeeze a reader into giving you their email address if there are links going other places? Read more

Adding SVN Information to File Headers Revisited

You may already be familiar with my previous post on Adding SVN Information to File Headers. After further review, I have decided to update the content to be more explicit. I want to better define how to establish the keywords and their usage in subversion repositories.

If you want to apply a standardized header to the files you are committing to your svn repository, you must first define the keyword list that you want to use. For this explanation and ease of use, I will use the same set of keywords I used in the previous post. Here is the sample header you can add to the top of your file. I use this specifically with php. Read more

Web Journalism Manifesto For Digital Age

I just finished reading an article about a a group of German bloggers who wrote a “Web Journalism Manifesto” describing how they believe journalism functions on the internet. There is a raging battle over content, the new commodity of the 21st century. Who owns it? How does one better utilize it? What can be done with it?

It rings true that due to the way the internet works, accessibility is greater than ever before. Anyone with access to a computer and a connection can add to the vast collection of data that exists in this digital world. There are virtually no rules. Anyone can write anything about any topic. Then it gets added to the online world indefinitely. Even if the submitted deletes the original, it will be cached somewhere. It will still be available even if not in original form. Interestingly though, the dregs of the internet only surface when they are stirred. Eventually the aged information sinks to the bottom of the digital pile as the new is laid down over the top of the old. It never really disappears, just merely forgotten. Read more