Example of the name that is in the DB: José ALberto da Silva Nogueira. I would like you to show only José Nogueira.
<?php if(!Yii::$app->user->isGuest) echo Yii::$app->session->get('nomeUsuario'); ?>
Example of the name that is in the DB: José ALberto da Silva Nogueira. I would like you to show only José Nogueira.
<?php if(!Yii::$app->user->isGuest) echo Yii::$app->session->get('nomeUsuario'); ?>
Follow the code below:
if(!Yii::$app->user->isGuest) {
$nomeCompleto = Yii::$app->session->get('nomeUsuario');
$partes = explode(" ", $nomeCompleto);
echo $partes[0] . " " . $partes[count($partes) - 1];
}