I'm having problems checking a string using EMPTY (), it's the following .. If I play space on it, it "" is no longer empty .. and ends up inserting in the database the empty value, how can I solve this, what function ?
I'm having problems checking a string using EMPTY (), it's the following .. If I play space on it, it "" is no longer empty .. and ends up inserting in the database the empty value, how can I solve this, what function ?
Remove spaces around the value before applying empty
:
$valor = " ";
$valor = trim($valor);
if(empty($valor)) {
echo "Sim, está vazio";
}
The function trim
removes the following characters, considered "blank", from the two ends of the string: