Code:
$dim = substr($dim, length($dim)-1, 1);