Convert string to int in PHP

Here’s another quick tip.  If you have an integer value stored as a string and want to convert it to an “int” type, this tip is for you.  You might want to use this if you’ve read an integer from a text file and therefore it was read in as a string value, but now you want to do a numeric comparison.  Anyways, on to the tip.  The following code converts a the string “25” to integer format.

Read moreConvert string to int in PHP

Check if a variable is an array in Javascript

Here’s a quick tip. When writing javascript and trying to test if a given variable is an array or not, I originally used the method of using the “typeof” operator. Unfortunately, because an array in Javascript is just another type of object, typeof will return “object” for an array variable.

So… instead, it’s recommended (by the people of the internet) that you use the “toString” method which will return a specific string for Array objects.  The following code demonstrates this:

Read moreCheck if a variable is an array in Javascript