Check string length in PHP

Solution 1:

Try the common syntax instead:

if (strlen($message)<140) {
    echo "less than 140";
}
else
    if (strlen($message)>140) {
        echo "more than 140";
    }
    else {
        echo "exactly 140";
    }

Solution 2:

[0]=> string(141) means $message is an array so you should do strlen($message[0]) < 141 ...

Solution 3:

[0]=> string(141) means that $message is an array, not string, and $message[0] is a string with 141 characters in length.

Solution 4:

$message is propably not a string at all, but an array. Use $message[0] to access the first element.