Skip to content

Instantly share code, notes, and snippets.

@sheershoff
sheershoff / php-multidimensional-array-search-return-keys.php
Last active August 5, 2019 10:49
php recursive search multidimensional array for value and return key sequences
<?php
namespace common\helpers;
class ArrayHelper extends \yii\helpers\ArrayHelper
{
public static function multiSearch($needle, $haystack, $options = ['strict' => false, 'yiiFormat' => false])
{
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator([$haystack]));
// parent array is skipped in subiterators, so we wrap the argument in one more array
$results = [];
@simonhamp
simonhamp / AppServiceProvider.php
Last active June 12, 2024 11:05
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()