29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Helper Functions 272<br />

.<br />

22 ],<br />

23 [<br />

24 'JavaScript',<br />

25 'PHP',<br />

26 'Ruby',<br />

27 ]<br />

28 ];<br />

29 */<br />

array_where() {#collection-method}<br />

The array_where function filters the array using the given Closure:<br />

.<br />

1 $array = [100, '200', 300, '400', 500];<br />

2<br />

3 $array = array_where($array, function ($key, $value) {<br />

4 return is_string($value);<br />

5 });<br />

6<br />

7 // [1 => 200, 3 => 400]<br />

head() {#collection-method}<br />

The head function simply returns the first element in the given array:<br />

.<br />

1 $array = [100, 200, 300];<br />

2<br />

3 $first = head($array);<br />

4<br />

5 // 100<br />

last() {#collection-method}<br />

The last function returns the last element in the given array:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!