PHP code example of liupei / phptools

1. Go to this page and download the library: Download liupei/phptools 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/ */

    

liupei / phptools example snippets


$arr2 = [
    [
        "key"=>1,
        "name"=>'name1'
    ]   
];
$_arr2 = \liupei\phptools\Arrays::array2SetKey($arr2, 'key');
var_dump($_arr2);
//$arr2 = [
//    1 => [
//        "key"=>1,
//        "name"=>'name1'
//    ]   
//];

$url = new \liupei\phptools\Url('http://www.baidu.com/index.php?name=liupei&age=18#task?id=1&back_url=ddd');

$url->addQuery("param1", "value1");

$url->addFragmentQuery("param1", "value1");

$urlStr = $url->buildUrl();

$id = \liupei\phptools\Id::createUniqueId();
var_dump($id);

$needel = 'a';
$haystack = 'a,b';
$in = \liupei\phptools\String::inString($needel,$haystack);
var_dump($in);
// true