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
- Composer create project laravel/laravel example app
- Docker important commands to run laravel application with docker
- Convert input array to comma-separated string in laravel controller
- Get last record from table in laravel
- How to show data by ID in laravel?
- How to get single column value in laravel
- Pagination in laravel
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project
- How to prevent host header attack in Laravel
- Call to undefined method App\Models\User::follow()
- Best Practices for Error Handling in Production Server Code (example code)
- How to get all posts which contains comments in laravel
- Get the post details if it has at least one comment in comments table
- Update email with unique validation in laravel
- Remove public from url in laravel project
- How to check if user has created any post or not in laravel
- After image selected get validation error in laravel
- How to insert dynamic values to additional column with pivot column in pivot table on multiple records
- Laravel 9 route group with controller
- Get Array of IDs from Eloquent Collection
- How to validate URL with https using regex in laravel
- How to pass data to partial view file in laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- How to check column value of a record is null or not in laravel
- Symlink(): No such file or directory