Skip to main content

Popular String Functions: Open-Source Examples

Premium
4 min read

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 of our courses? (30 h 41 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

L
lawries ✓ Link copied!

Great article - thanks

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.