// using my personal library of functions for PHP...
// I will test this when I get back to my computer at home, but it should work... basically the two functions should be self explanatory.. I should mention though that these functions are not built just to make it seem small, I use these quite a bit... and of course I have much more complicated ones for more complicated tasks