Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object
Perhaps check out the units library? There doesn't seem to be a PHP binding for it, though.