1. Go to this page and download the library: Download anahkiasen/underscore-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anahkiasen / underscore-php example snippets
use Underscore\Types\Arrays;
$array = array(1, 2, 3);
// One-off calls to helpers
Arrays::each($array, function($value) { return $value * $value; }) // Square the array
Function::once($myFunction) // Only allow the function to be called once
Number::paddingLeft(5, 5) // Returns '00005'
Object::methods($myObject) // Return the object's methods
Strings::length('foobar') // Returns 6
// Or chain calls with the 'from' method
Arrays::from($array)->filter(...)->sort(...)->get(2)
// Which does this in the background
$array = new Arrays($array);
$array->filter(...)->sort(...)->get(2)
class Users extends Arrays
{
public function getDefault()
{
return 'foobar';
}
public function getUsers()
{
// Fetch data from anywhere
return $this->setSubject($myArrayOfUsers);
}
}
$users = new Users; // Users holds 'foobar'
$users->getUsers()->sort('name')->clean()->toCSV()
// Same as above
Users::create()->getUsers()->sort('name')->clean()->toCSV()
Arrays::diff($array, $array2, $array3) // Calls `array_diff`
Arrays::from($array)->diff($array2, $array3)->merge($array4) // Calls `array_diff` then `array_merge` on the result
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.