How-to articles, tricks, and solutions about PHP
Best way to do a PHP switch with multiple values per case?
To get specific attributes from a Laravel Collection, you can use the pluck method.
Best way to give a variable a default value (simulate Perl ||, ||= )
The best way to give a variable a default value in PHP is to use the ternary operator ?:.
Calculate age based on date of birth
Here is some sample PHP code that calculates a person's age based on their date of birth: