OK I am writing a custom snippet and it refers to a TV which varies from page to page to represent different resorts.
The different resorts have an id which is a number so to check the status of a value I am checking its status like this:
$downhill = ’[+resortinfo_Downhill_[*resort_id*]+]’;
If I echo this I get either "yes" or "no" as an output (correctly) depending on which resort I am referring to via the TV.
Now if I do a
strlen($downhill);
The result is 37 which has me baffled. The database field is a varchar(3) so it can’t be any longer than 3.
I figured perhaps it is only resolving to a string on echo somehow so I have even tried (string) $downhill and it is still stringlength 37.
All I want to do is a simple if then comparision
if ($downhill == ’yes’) {
do this
}
But it never equates to yes, even though on echo it does. I have tried trim($downhill) with no effect, still strlen 37.
I know this is cumbersome but I am trying to identify every step to work out what is happening.
$downhill = '[+resortinfo_Downhill_[*resort_id*]+]';
$downhill1 = (string) $downhill;
$downhill2 = trim($downhill1);
echo 'downhill : -'.$downhill2.'-<br>';
results in : downhill : -yes-
If I look at the source html there are no returns or anything hiding there between the two -’s just -yes-
Yet if I compare $downhill2 == ’yes’ it always fails and I suspect the string length is the issue but I just can’t get my head around why the stringlength would be 37 when the database entry is a varchar(3) and has a value of yes and that is returning!
Any ideas, would be greatly appreciated.