Skip to content

Instantly share code, notes, and snippets.

Avatar

afolabi legunsen aphoe

View GitHub Profile
@aphoe
aphoe / implode-and.php
Last active May 14, 2020
PHP function to 'implode' array into a sentence, using 'and' before the last item
View implode-and.php
<?php
if(!function_exists('implodeAnd')){
/**
* Implode array into asentence
* @param array $haystack
* @param string $glue
* @param string $and
* @return string
*/
function implodeAnd(array $haystack, string $glue=', ', string $and = ' and '): string
@aphoe
aphoe / checkRoute.php
Last active Jul 23, 2020
Function to check if a route exists in Laravel 5
View checkRoute.php
/**
* @param $route
* @return bool
*/
function checkRoute($route) {
$routes = \Route::getRoutes()->getRoutes();
foreach($routes as $r){
if($r->getUri() == $route){
return true;
}
You can’t perform that action at this time.