PHP code example of seffeng / laravel-helpers
1. Go to this page and download the library: Download seffeng/laravel-helpers 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/ */
seffeng / laravel-helpers example snippets
/**
* TestController.php
* 示例
*/
namespace App\Http\Controllers;
use Seffeng\LaravelHelpers\Helpers\Arr;
use Seffeng\LaravelHelpers\Helpers\Json;
use Seffeng\LaravelHelpers\Helpers\Time;
use Seffeng\ArrHelper\ReplaceArrayValue;
class TestController extends Controller
{
public function index()
{
$arr = [
'a' => [
'b' => [
'c' => 'ccc'
]
],
'd' => [
'b' => 'ccc',
'e' => [
'f' => 'hhh'
]
]
];
echo '<pre>';
var_dump(Arr::get($arr, 'a.b.c', ''));
var_dump(Arr::getDepth($arr));
print_r(Arr::getColumn($arr, 'b'));
print_r($arr);
print_r(Arr::merge($arr, [
'd' => new ReplaceArrayValue(['hhh' => 'iii']),
'i' => [
'j' => 'kkk'
]
]));
$json = Json::encode($arr);
var_dump($json);
print_r(Json::decode($json));
var_dump(Time::asWeekCN(time()));
}
}
+---src
| +---Commands
| | Crypt.php
| +---Handlers
| | CacheHandler.php
| +---Helpers
| | Arr.php
| | Json.php
| | Str.php
| | Time.php
| | Util.php
| | Xml.php
| \---Listeners
| QueryExecutedListener.php
+---tests
| ArrTest.php
| JsonTest.php
| StrTest.php
| TimeTest.php
| UtilTest.php
| XmlTest.php