Generate Excerpt without Breaking a Word

Here’s a little snippet for generating an excerpt without breaking up a word: function excerpt($string=”, $maxChar=50, $uri=’#’) { $length = strlen($string); if ($length < $maxChar) { return $string; } $trimmedString = substr($string, 0, $maxChar); $choppedString = substr($trimmedString, 0, strrpos($trimmedString, strrchr($trimmedString, ‘ ‘))); $newString = $choppedString . ‘ <a href=”‘ . $uri . ‘”>more</a>’; return $newString;… Continue reading Generate Excerpt without Breaking a Word

Categorized as snippets Tagged

Laravel Project Setup

First, get composer if you don’t already have it (Windows): I like to use the composer installer (as opposed to the Laravel Installer). Open command prompt and move into www directory (or wherever you want your project to live). composer create-project laravel/laravel name-of-project   This will create the directory “name-of-project” and place all the laravel… Continue reading Laravel Project Setup

Set up Laravel Environment on Elementary OS

Install Apache, PHP, MySQL You can probably skip this part if you’re going to only use Homestead. Just skip down to Install Composer. Apache Add Apache respository sudo add-apt-repository ppa:ondrej/apache2 Install Apache sudo apt-get update sudo apt-get install apache2