User attribute not comparing to string successfully.

Permalink
I am having users store data on sign up. Later, I am putting that data using:
use Concrete\Core\User\UserInfo;
$u = new User();
$ui = UserInfo::getByID($u->getUserID());
$testtype = $ui->getAttribute('TestType','display');

When I compare this (on this user, it is stored as "English Adult Male") to a string literal, it doesn't succeed. The string literal is 18 characters, a var_dump of the variable shows it's 23. It looks like it ends in a space with a carriage return. I have tried to use the 'trim" function, but it still returns 23 characters.

Is there something about the data being stored in concrete5 that I need to know to get this condition to test true?

GeeEM
 
mnakalay replied on at Permalink Best Answer Reply
mnakalay
Hello. When you use the 'display' parameter to the getAttribute() function, it doesn't send you back the raw data, it returns a nicely formatted string to be displayed to the view so it can add anything to it: markup, carriage returns...

What you want to do is
$testtype = $ui->getAttribute('TestType');
GeeEM replied on at Permalink Reply
GeeEM
Ah, I added that because it wasn't working for some number comparisons without it. As that's not needed here, I will modify it. Thanks!