<?php include getcwd() . '../vendor/autoload.php'; $array = array('element1', 'element2'); $arrayManipulator = new Moriony\Trivial\Manipulator\ArrayManipulator(); $result = $arrayManipulator->randomElements($array, 3); print_r($result);
<?php include getcwd() . '../vendor/autoload.php'; $array = array('element1', 'element2'); $arrayManipulator = new Moriony\Trivial\Manipulator\ArrayManipulator(); $result = $arrayManipulator->randomElement($array); print_r($result);
<?php include getcwd() . '../vendor/autoload.php'; $array = array(array("result" => "success", "user" => "Duffy", "message" => "11111111111oneoneoneone!!!"), array("result" => "error", "user" => "Porky", "message" => "22222222222twotwotwotwo!!!")); $arrayManipulator = new Moriony\Trivial\Manipulator\ArrayManipulator(); $result = $arrayManipulator->group($array, array(function ($item) { return $item['user']; }, function ($item) { return $item['result']; })); print_r($result);