Skip to content

Instantly share code, notes, and snippets.

View ahkmunna's full-sized avatar

Munna Khan ahkmunna

View GitHub Profile
$arr = range(10,100);
$i=1; $j=4;
foreach($arr as $value)
{
echo '*'; // Print the column
@ahkmunna
ahkmunna / gist:883b635e6f438e253837a1b6ea13307a
Created August 7, 2018 08:59
Remove parameter from the URL query string.
if ( ! function_exists('remove_url_parameter') )
{
/**
* Remove given parameter from the given url str
*/
function remove_url_parameter($url, $key = false)
{
return preg_replace( '/'. ($key ? '(\&|)' . $key . '(\=(.*?)((?=&(?!amp\;))|$)|(.*?)\b)' : '(\?.*)').'/i' , '', $url);
}
}
@ahkmunna
ahkmunna / gist:210e5cd19c72942b8520f65a879447bd
Last active August 6, 2018 22:23
Add pagination functionality on Laravel collections. Add this macro in the boot method in AppServiceProvider
// Add pagination on collections
if (!Collection::hasMacro('paginate')) {
Collection::macro('paginate',
function ($perPage = 15, $page = null, $options = [])
{
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
return (new LengthAwarePaginator(