“The program can’t start because php5ts.dll is missing from your computer” Error

I was trying to execute a PHP file via the command line on a windows machine and got the following error “the program can’t start because php5ts.dll is missing from your computer” Now executing PHP via the command line in Windows is different enough from Linux, I didn’t know what it needed. In Linux I would have install php-cli which should have come with all the dependancies. In Windows however, I fixed the issue by...

Read More

Removing extra spaces from within quotes of a string in PHP

Every once in a while, you may be building strings that include quoted material. The issue is that if you’re doing it programmatically, you may be doing something that quotes different parts of the string. The issue is, that if the field you’re pulling from doesn’t exist, you may leave yourself with extra spaces in your strings. See the example below. Table: A Columns: color,number,price,shape Row1: red,4,3.25,square Row2:...

Read More

ERROR: `phpize’ failed and make: *** [oauth.lo] Error 1

I recently tried to install oauth on Ubuntu and got two errors during the process. Unlike what is said, it was not the simple install from pecl. sudo pecl install oauth This should work, but it threw my first error ERROR: `phpize’ failed More searching revealed that the phpize script is found in the php5-dev package, and those who had the error installed that to make it work. sudo apt-get install php5-dev It got farther this time, but...

Read More

Parse a CSV file line in PHP

Parse a CSV file line in PHP

PHP has great string manipulation tools for importing files like fgets() to get a single line or file() to dump the lines into an array right at import. Explode is a great function when you start dealing with the contents of the file. However, if you’re bringing in a standardized file, like a CSV, there are some issues with explode. For instance, a comma may be in a string in the middle of the field, so you can’t break it apart on...

Read More

PHP Levenshtein distance

Levenshtein distance is a way of calculating how different two strings are. This function is extremely helpful in determining if a user made a mistake in entry, trying to find similar inputs, or comparing strings for any reason. The Levenshtein distance is a numeric value of how many changes are necessary to turn the one string into the other. There are default weights assigned to different operations like Capitalizing a letter or...

Read More

PHP Fatal error: Unsupported operand types

PHP is a very flexible language, but sometimes you’re not passing it what you expect. If you’re trying to do arithmetic, PHP will handle and convert pretty much anything except an array. So chances are if you get the “Fatal error: Unsupported operand types in” error, then you’re not adding two variables that you think you are. To troubleshoot simply do a var_dump(); before the operation that it is erroring out at...

Read More