1. Go to this page and download the library: Download marsapp/maphelper 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/ */
marsapp / maphelper example snippets
// Use namespace
use marsapp\helper\mapping\MapHelper;
// Data
$data = [
['c_sn' => 'a110', 'u_sn' => 'b1', 'u_no' => 'a001', 'u_name' => 'name1'],
['c_sn' => 'a110', 'u_sn' => 'b2', 'u_no' => 'b012', 'u_name' => 'name2'],
];
// Index by
MapHelper::add($data, 'userInfo', ['c_sn', 'u_no']);
// Get name by a110 => a001 => u_name
$name = MapHelper::getMap('userInfo', ['a110', 'a001', 'u_name']);
// $name = name1;
init(string $mapName = null) : MapHelper
// Use namespace
use marsapp\helper\mapping\MapHelper;
// Clear the Map cache with the specified name, like: userInfo.
MapHelper::init('userInfo');
//Clear all Map cache.
MapHelper::init();
// Use namespace
use marsapp\helper\mapping\MapHelper;
// Data
$data = ['lv1' => ['lv2' => ['2011-05-06' => '11', '2012-01-01' => '12', '2015-09-16' => '15']]];
// Add map
MapHelper::addRaw($data, 'testMap');
// Get data by location point.
$result = MapHelper::location('testMap', ['lv1', 'lv2'], '2011-12-05');
var_export($result);
// Output: 11
// Get data by location point.
$result = MapHelper::location('testMap', ['lv1', 'lv2'], '2012-12-05');
var_export($result);
// Output: 12
hasMap(string $mapName) : boolean
// Use namespace
use marsapp\helper\mapping\MapHelper;
// Add map
MapHelper::addRaw([1, 2, 3, 4], 'map1');
// Determine whether the target map table exists
$mapName = 'map1';
if (MapHelper::hasMap($mapName)) {
echo $mapName . ' Exist.';
} else {
echo $mapName . ' Not exist.';
}
mapList() : array
// Use namespace
use marsapp\helper\mapping\MapHelper;
// Add map
MapHelper::addRaw([1, 2, 3, 4], 'map1');
MapHelper::addRaw(['a', 'b'], 'map2');
// Get map name list and print it.
$mapList = MapHelper::mapList();
var_export($mapList);
// output: ['map1', 'map2']
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.