To infinity and beyond!

We can file this one under the “PHP functions I never knew existed and probably will never use” category. Seems that as of PHP 4.2.0 and beyond there was the inclusion of an is_finite() and an is_infinite() function. The names are pretty self explanatory and I’m sure there are some smart kids out there that would use these (although I’d expect them to be...

Read Full Article →

Finding the smallest or largest value

Figured I would keep up the trend of talking about finding the smallest and largest values in arrays by talking about finding the smallest or largest value in a set of values. Incidentally, doing so will utilize the same min() and max() functions we used previously. Not one of my favorite things, but PHP has a tendency to allow mixed input on some functions....

Read Full Article →

Find the largest value in an array

Last week we discussed how to find the smallest value in an array so it seemed fitting to discuss how to find the largest value in an array. As we previously discussed back in the day you would have to loop through an array and compare values until you found the smallest (or in this case largest) value. As a complement to the min()...

Read Full Article →

Find the lowest value in an array

Finding the lowest value of an array is a pretty common task in PHP, especially when you are dealing with things like scores or money. In the old days before PHP 4, finding the lowest value of an array meant looping through the array and comparing values until you had the lowest one, something like this: $array = array(6, 2, 10, 4, 15); $lowest...

Read Full Article →

How to convert an array to a string

Converting an array to a string is a pretty frequent task when programming. Whether you want to join some sentences into a paragraph or just smash the values into some sort of hash, you can do so very simply with PHP’s implode function. Implode takes 1 to 2 arguments. In it’s simplest form, you can pass it your array and the values will be...

Read Full Article →