Part of the reason that this is complicated is that there are lots of ways to accomplish this function and I am taking your lead and doing it your way - which is a way that I wouldn't necessarily do it myself. But let's assume that we do it your way for a minute.
Let's say you have a field called $customername and it's currently equal to "John Smith".
One way to solve the problem is to pass "John Smith" to the function. Of course, as you pointed out, this won't allow the function to know which variable was being evaluated.
So the other way to solve the problem is to pass "customername" to the function. I don't mean pass $customername. I mean, pass the string "customername". c - u - s - t - o - m - e - r - n - a - m - e.
Now, once the function has that string, it can make a variable variable. So if your function receives $fieldname, then the variable $fieldname is equal to "customername". And once the function knows that, then it can check the contents of $$fieldname. When you replace ($fieldname) with "customername", then you end up with $customername.
And that would be fine. Then you could say:
if (strlen($$fieldname)>1) { blah blah blah
EXCEPT that $customername DOESN'T HAVE ANY VALUE inside the function. Why? Because that variable isn't local to the function. So you have to use the global command to make $$fieldname (which is $customername) local to the function.
In other words, my code works fine as long as you pass the NAME of the variable that should be evaluated. Don't pass the variable to be evaluated - pass the NAME of the variable to be evaiuated. (Just as laserlight suggested).