Question

I'm trying to execute the following simple command, but it's not returning any result:

$val = substr($gesprek->gevormdnummer, 0, 2);

The $gesprek->gevormdnummer value is a phone number fetched from the database (stored as varchar(50)). I'm using the Yii framework to get the data from the MS SQL Database. I'm running PHP 5.5.8 NTS on IIS7.5.

If I echo the variable it returns for example 00497121212 or 511 depending if it's an internal or external number.

When I change $gesprek->gevormdnummer to for example '511', substr will work correctly. I've tried using mb_substr with UTF-8 encoding but that returns the same result.

Is there anybody who has an idea what the problem might be?

Was it helpful?

Solution

CBroe gave the to finding the answer to my problem. The string was prefixed with spaces till there we're 16 characters.

So the substr was working correctly, i got back 2 spaces, which didn't show up in the echo.

var_dump($var) gave me the insight to find this out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top