First commit
This commit is contained in:
112
longbingcore/tools/LongbingArr.php
Executable file
112
longbingcore/tools/LongbingArr.php
Executable file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace longbingcore\tools;
|
||||
|
||||
|
||||
class LongbingArr
|
||||
{
|
||||
/**
|
||||
* 根据Key删除素组值
|
||||
*
|
||||
* @param $arr
|
||||
* @param $key str\array
|
||||
* @return mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/25 17:32
|
||||
*/
|
||||
public static function delBykey($arr , $key)
|
||||
{
|
||||
|
||||
|
||||
if(is_array($key)){
|
||||
foreach ($key as $k => $v){
|
||||
$arr = self::delBykey($arr , $v);
|
||||
}
|
||||
return $arr ;
|
||||
}
|
||||
|
||||
if(!array_key_exists($key, $arr)){
|
||||
return $arr;
|
||||
}
|
||||
$keys = array_keys($arr);
|
||||
$index = array_search($key, $keys);
|
||||
if($index !== FALSE){
|
||||
array_splice($arr, $index, 1);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除多维数组,根据
|
||||
*
|
||||
* @param $array
|
||||
* @param $key
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/25 22:37
|
||||
*
|
||||
* demo
|
||||
* $details = array(
|
||||
* 0 => array("id"=>"1", "name"=>"Mike", "num"=>"9876543210"),
|
||||
* 1 => array("id"=>"2", "name"=>"Carissa", "num"=>"08548596258"),
|
||||
* 2 => array("id"=>"1", "name"=>"Mathew", "num"=>"784581254"),
|
||||
* );
|
||||
* $details = unique_multidim_array($details,'id');
|
||||
* Output will be like this :
|
||||
* $details = array(
|
||||
* 0 => array("id"=>"1","name"=>"Mike","num"=>"9876543210"),
|
||||
* 1 => array("id"=>"2","name"=>"Carissa","num"=>"08548596258"),
|
||||
* );
|
||||
*/
|
||||
public static function unique_multidim_array($array, $key) {
|
||||
$temp_array = array();
|
||||
$i = 0;
|
||||
$key_array = array();
|
||||
|
||||
foreach($array as $val) {
|
||||
if (!in_array($val[$key], $key_array)) {
|
||||
$key_array[$i] = $val[$key];
|
||||
$temp_array[$i] = $val;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $temp_array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把所有的一级数组进行合并,主要用于 event 返回数据进行合并
|
||||
*
|
||||
* @param $array
|
||||
* @return mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/26 11:04
|
||||
*
|
||||
* demo
|
||||
*
|
||||
* $array = [ [0,1,2] , [3,4] ]] ;
|
||||
* LongbingArr::array_merge($array);
|
||||
* $returnArray = [0,1,2,3,4] ;
|
||||
*/
|
||||
public static function array_merge($array){
|
||||
$returnArr = [];
|
||||
foreach ($array as $item){
|
||||
if(!empty($item)) $returnArr = array_merge($returnArr,$item);
|
||||
}
|
||||
return $returnArr;
|
||||
}
|
||||
|
||||
}
|
||||
53
longbingcore/tools/LongbingDefault.php
Executable file
53
longbingcore/tools/LongbingDefault.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace longbingcore\tools;
|
||||
|
||||
|
||||
class LongbingDefault
|
||||
{
|
||||
public static $avatarImgUrl = 'https://retail.xiaochengxucms.com/defaultAvatar.png' ;
|
||||
public static $notImgUrl = 'https://retail.xiaochengxucms.com/lbCardDefaultImage.png' ;
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $target
|
||||
* @param $default
|
||||
* @param $defaultArr
|
||||
* @功能说明: 格式换默认图片
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020/1/17 11:32
|
||||
*/
|
||||
public static function formatDefaultImage ( $data, $target, $default, $defaultArr )
|
||||
{
|
||||
|
||||
foreach ( $data as $index => $item )
|
||||
{
|
||||
if ( is_array( $item ) )
|
||||
{
|
||||
$data[ $index ] = formatDefaultImage( $item, $target, $default, $defaultArr );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($index == $target && $item == '' && isset($defaultArr[$default]))
|
||||
{
|
||||
$data[$index] = $defaultArr[$default];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
47
longbingcore/tools/LongbingImg.php
Executable file
47
longbingcore/tools/LongbingImg.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace longbingcore\tools;
|
||||
|
||||
|
||||
class LongbingImg
|
||||
{
|
||||
/**
|
||||
* 检查远程图片是否存在
|
||||
*
|
||||
* @param $imgUrl
|
||||
* @return bool
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/28 10:17
|
||||
*/
|
||||
public static function exits($imgUrl) {
|
||||
|
||||
if(empty($imgUrl)){
|
||||
return false ;
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,$imgUrl);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, 1); // 不下载
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
if(curl_exec($ch)!==false)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
37
longbingcore/tools/LongbingStr.php
Executable file
37
longbingcore/tools/LongbingStr.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace longbingcore\tools;
|
||||
|
||||
|
||||
class LongbingStr
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @功能说明:转utf 8
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 19:23
|
||||
*/
|
||||
|
||||
static public function strToUtf8($str){
|
||||
$encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));
|
||||
if($encode == 'UTF-8'){
|
||||
return $str;
|
||||
}else{
|
||||
return mb_convert_encoding($str, 'UTF-8', $encode);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
longbingcore/tools/LongbingTime.php
Executable file
76
longbingcore/tools/LongbingTime.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace longbingcore\tools;
|
||||
|
||||
|
||||
class LongbingTime
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @功能说明:转utf 8
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 19:23
|
||||
*/
|
||||
|
||||
public static function getChinaNowTime(){
|
||||
return date('Y-m-d H:i:s', time() ) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param string $field
|
||||
* @功能说明:格式化友好时间
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020/1/17 10:26
|
||||
*/
|
||||
public static function frendlyTime ( $data, $field = 'create_time' )
|
||||
{
|
||||
// 今天的时间戳
|
||||
$time = time();
|
||||
// 昨天的时间戳
|
||||
$Yesterday = $time - (24 * 60 * 60);
|
||||
|
||||
$today = mktime(0, 0, 0, date("m", $time), date("d", $time), date("Y", $time));
|
||||
$Yesterday = mktime(0, 0, 0, date("m", $Yesterday), date("d", $Yesterday), date("Y", $Yesterday));
|
||||
|
||||
foreach ($data as $index => $item) {
|
||||
$tmpTime = $item[$field];
|
||||
if ($tmpTime > $today) {
|
||||
// $data[ $index ][ 'radar_time' ] = '今天 ';
|
||||
$data[$index]['radar_group'] = '今天';
|
||||
$data[$index]['radar_time'] = date('H:i', $item[$field]);
|
||||
} else if ($tmpTime > $Yesterday) {
|
||||
// $data[ $index ][ 'radar_time' ] = '昨天 ';
|
||||
$data[$index]['radar_group'] = '昨天';
|
||||
$data[$index]['radar_time'] = date('H:i', $item[$field]);
|
||||
} else {
|
||||
$thisYear = date('Y');
|
||||
$itemYear = date('Y', $item[$field]);
|
||||
if ($thisYear == $itemYear) {
|
||||
$data[$index]['radar_group'] = date('m-d', $item[$field]);
|
||||
$data[$index]['radar_time'] = date(' H:i', $item[$field]);
|
||||
} else {
|
||||
$data[$index]['radar_group'] = date('Y-m-d', $item[$field]);
|
||||
$data[$index]['radar_time'] = date(' H:i', $item[$field]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user