Laravel Gripes

By | 05/12/2019

Only a couple of weeks into Laravel and trivial but feels like it doesn’t support – for want of a better phrase, pythonic syntax. I’m more lines of code than I would in Ruby or Python oh and there are lots of types of arrays… you have to declare it’s an array also!

$myArray = [‘one’, ‘two’, ‘three’] # php
myArray = [‘one’, ‘two’, ‘three’] # ruby

To shuffle the array

PHP

<?php
$myArray = ['one', 'two', 'three'];
shuffle($myArray);
foreach ($myArray as $item)
  echo $item;
Ruby
myArray = ['one', 'two', 'three'].shuffle
puts myArray