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
- Include External CSS and JS file in Laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- How to Get records between two dates in Laravel
- How to check records exist in loaded relationship in Laravel blade view
- How to check column value of a record is null or not in laravel
- How to use more than one query scope in Laravel
- How to include header file in laravel
- How to insert dynamic value to additional column in pivot table in laravel
- Ajax GET request in laravel
- Generate unique username in Laravel
- Shorter syntax for whereHas with call back function in laravel
- How to Access Array in blade laravel
- Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
- Class 'App\Rules\Hash' not found in Laravel
- How to create project_user pivot table in laravel
- How to display user profile after login in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Redirect to another view from controller in laravel
- How to delete record in Laravel with ajax
- Get laravel version
- How to create belongstomany relation using custom name on custom pivot table
- How to run a specific seeder class in laravel
- Define variable and use in Laravel controller method
- How to get user information using hootlex/laravel-friendships package in laravel
- Add a subselect based on relationship using withAggregate method