Fixed  PHP notices

Added some indentation for readability and fixed a couple of `undefined offset` PHP notices