This simple image class will allow you to get an image from your server to dynamically resize it and center it top/bottom and left/right in a square box. If you have some images that are all good kb size but are a bit random in their dimensions, you can use this class to make them fit dynamically in a box. It will make images that are larger than the bounds of the box smaller, but will not adjust the size of images that are smaller than then bounds. That would make them blurry, so instead it just makes them centered in the box.
I am using this in a scenario where there are images that have been uploaded to the server that are very small 200×200 and rather large 1000×1200. The size of my display box in this example is 400×400.
I have created a way to always center an image in a DIV container. This has been a thorn in my side as CSS is not my strongest skill.
So here is the concept. Have a container DIV that has a fixed width and height. Then use the GD Library installed with PHP to get the image size that is being displayed inside the DIV. Then subtract the image height from the container height and divide by two. You can do the same for the height.
I have written a simple php class that handles regular expressions. Once instantiated it can remove characters, numbers, words, letter, or custom expressions from a string. It does not require you to know any of the syntax for implementation. It simply returns the value of the string with the pattern removed.
So i have these commonly used arrays for <select> inputs. I generally place these in a library.php file or at the top of a file with a ton a functions so that i have access to them as globals
I just want to write about a great resource that i contribute to and use a lot. Hyperspatial has a code collective of snippets and frequently used code that is a good tool to use to find commonly used little tid bits.
Here is a link to the code that i have submitted over there.