
How to display a specific word from a string in laravel
How to display a specific word from a string in laravel
In this session, we are going to try to solve the "How to display a specific word from a string in laravel" puzzle by using the computer language.
You can display the specific word from string by converting the string to an array and after that you can get the value of each array element by passing the key to the array.-
Display first word from name in laravel view after getting the name of user
//It will display the first name of user @php $userName = explode(' ', $user->name); @endphp <p>{{ ucfirst($userName[0]) }}</p>
This code snippet will help you to get the first word from the user name. Sometimes we have a full name in a single column field and we want to display the first name instead of surname then we can display the first name from the full name in the laravel view without changing the controller or model code in laravel.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Laravel pagination links with query string
- 419 page expired error in Laravel
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- Composer\Exception\NoSslException
- Get count of filter data, while return a small set of records
- How to get last month records in Laravel
- Laravel upload file with original file name
- Laravel csrf token mismatch for ajax POST Request
- If condition in Laravel 9
- Submit form without CSRF token in Laravel
- Global scope in Laravel with example
- How to create and run user seeder in laravel
- SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
- Route prefix with auth middleware in laravel
- How to get column names from table in Laravel
- How to check relationship is loaded or not in Laravel
- Show old value while editing the form in Laravel
- External link not working in laravel blade
- How to pass two variables in HREF in laravel
- How to insert value to additional columns in pivot table in laravel
- Ajax POST request in laravel
- Get last week data in Laravel
- Display message with session flash using bootstrap alert class in laravel
- Update email with unique validation in laravel
- SQLSTATE[42000]: Syntax error or access violation: 1055