laravel/framework — pull request #3573 by colindecarlo (2014-02-16 14:53:46+00:00)
Title: [Bug] Request::segment returns incorrect value when path contains an empty segment

The `Request::segment` method uses `array_filter` to remove empty segments from the `$segments` array, however `array_filter` also preserves the keys of the filtered array. This change uses `array_values` to rekey the filtered array.

Also, this change removes the closure used to filter the array as it wasn't providing anything useful since, by default, `array_filter` removes "falsey" values.

### Current Behaviour

```php
$request = Request::create('foo//bar', 'GET');
$segment = $request->segment(2, 'oops'); // $segment is 'oops'
```

### Corrected Behaviour

```php
$request = Request::create('foo//bar', 'GET');
$segment = $request->segment(2, 'oops'); // $segment is 'bar'
```