Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

APA-style titles in Laravel

APA-style titles are a specific type of title case that is used in academic papers, research reports, and journal articles. It’s a style that’s used by the American Psychological Association (APA) and is a variation of the title case.

For instance, the title “The quick brown fox jumps over the lazy dog” would be written as “The Quick Brown Fox Jumps Over The Lazy Dog” in the title case. But in APA style, it would be written as “The Quick Brown Fox Jumps Over the Lazy Dog”.

As you can notice, the only difference between the title case and APA-style is that the articles (a, an, the) are not capitalized in APA-style. That’s because the articles are not considered as important as the other words in the title.

Apart from the articles, the APA-style also doesn’t capitalize the coordinating conjunctions (and, but, for, nor, or, so, yet) and prepositions (e.g. in, on, of, to, with, etc.) that are less than five letters long.

So, recently, Laravel has been shipped with a brand new APA-style title helper which you can use to convert your titles to APA-style.

Here’s how you can use it.

use Illuminate\Support\Str;

echo Str::apa('The quick brown fox jumps over the lazy dog');
// The Quick Brown Fox Jumps Over the Lazy Dog

echo  Str::apa('back to the future');
// Back to the Future

echo Str::apa('SELF-REPORT');
// Self-Report

As you can tell, the helper is pretty smart and can handle a lot of different cases. It can even handle the hyphenated words and acronyms. I think it’s a pretty neat addition to the framework for the projects that use APA-style titles.

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a


👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.