Courses

PHP for Laravel Developers

Popular String Functions: Open-Source Examples

Summary of this lesson:
- Learn about common PHP string functions
- Understand string replacement and splitting techniques
- Explore string formatting and case manipulation
- Examine practical uses of string functions

There are many functions for working with strings. Let's check some of them and how they are used in Laravel open-source projects.


str_replace()

class HomeController extends Controller
{
// ...
 
public function pastebin(string $paste = ''): RedirectResponse
{
$paste = str_replace(PHP_EOL, '', $paste);
 
return redirect()->away("https://paste.laravel.io/$paste");
}
}

Link to the example in GitHub repository.


explode()

The explode function is one of the most popular functions. This function returns...

The full lesson is only for Premium Members.
Want to access all 16 lessons of this course? (52 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord