With this rule below, how do I show the user’s first and last names in the database?

Asked

Viewed 53 times

4

Example of the name that is in DB: José Alberto da Silva Nogueira. I’d like you to just show José Nogueira.

<?php if(!Yii::$app->user->isGuest) echo Yii::$app->session->get('nomeUsuario'); ?>

1 answer

4


Follows code:

if(!Yii::$app->user->isGuest) {
    $nomeCompleto = Yii::$app->session->get('nomeUsuario');
    $partes = explode(" ", $nomeCompleto);
    echo $partes[0] . " " . $partes[count($partes) - 1];
}
  • Thanks for your help Jhonatan.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.