Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Laravel 5 Essentials

You're reading from   Laravel 5 Essentials Explore the fundamentals of Laravel, one of the most expressive and robust PHP frameworks available

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher Packt
ISBN-13 9781785283017
Length 144 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Martin Bean Martin Bean
Author Profile Icon Martin Bean
Martin Bean
Arrow right icon
View More author details
Toc

String and text manipulation

The string manipulation functions are found in the Illuminate\Support namespace and are callable on the Str object.

Most of the functions also have shorter snake_case aliases. For example, the Str::endsWith() method is identical to the global ends_with() function. We are free to use whichever one we prefer in our application.

Boolean functions

The following functions return the true or false values:

  • The is method checks whether a value matches a pattern. The asterisk can be used as a wildcard character as shown here:
    Str::is('projects/*', 'projects/php/'); // Returns true
  • The contains method, as shown in the following code, checks whether a string contains a given substring:
    Str::contains('Getting Started With Laravel', 'Python');
    // returns false
  • The startsWith and endsWith methods, as shown in the following code, check whether a string starts or ends with one or more substrings:
    Str::startsWith('.gitignore', '...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image