Showing posts from the "PHP" category - page 2

  • Giving something a 'Last' Class

    If you want to apply a different class to the last item in a list generated by PHP, start off with Setting the $lastOne variable to the end of your list <?php $lastOne = end($your_array); This stores the details of the last one in your list into the lastOne

  • Using PHP to get the dimensions of an image

    The following code will get the dimensions of an image: <?php list($width, $height, $type, $attr) = getimagesize(PATH_TO_IMAGE); I found this useful when using a lightbox to load an image that I didn't initially know the size of, to ensure the lightbox positioned itself in the middle, based on the