This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*============================ | |
* author:Farmer | |
* time:2017/12/19 | |
* blog:blog.icodef.com | |
* function:加密方式 | |
*============================ | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data[] = array('volume' => 67, 'edition' => 2); | |
$data[] = array('volume' => 86, 'edition' => 1); | |
$data[] = array('volume' => 85, 'edition' => 6); | |
$data[] = array('volume' => 98, 'edition' => 2); | |
$data[] = array('volume' => 86, 'edition' => 6); | |
$data[] = array('volume' => 67, 'edition' => 7); | |
print_r($data); | |
$column = array_column($data, 'edition'); | |
array_multisort($column, SORT_DESC, $data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 查找数组中上一个元素键/值,下一个元素键/值 | |
* @param str $currentValue 当前元素的值 | |
* @param array $array 待查询数组 | |
* @return array 上一个元素键/值,下一个元素键/值 | |
*/ | |
public function arrayPrevNext($currentValue, $array) | |
{ | |
$prev_key = $next_key = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait Service_Data_Base_Singleton | |
{ | |
private static $singleton; | |
private function __construct(){} | |
public static function getInstance() { | |
if( !(self::$singleton instanceof self) ) { | |
self::$singleton = new self(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
/** | |
* 对二维数组去重 | |
* @param $array2D | |
* @return array | |
*/ | |
function unique_array_more($array2D) | |
{ | |
foreach ($array2D[0] as $key => $value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function filterArray($oldArray,$keyArray) | |
{ | |
$newArray=array_intersect_key($oldArray, array_flip($keyArray)); | |
return $newArray; | |
} | |
$promotion = array_intersect_key($promotion, array('id', 'promotion_id', 'promotion_actived', 'promotion_title', | |
'promotion_detail', 'promotion_type', 'promotion_type_name', 'sku_info', 'start_time', 'cancel_time','effect_scene')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 数组按某一个元素值进行分组,正如数据库的group by语句 | |
* @param $array | |
* @param $key | |
* @return array | |
*/ | |
public function array_group_by($array, $key) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$abnormalOrderIds = array_filter($abnormalOrderIds, function ($item) use ($completeOrders) { | |
return !isset($completeOrders[$item['code']]); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
/* | |
* 判断两个数组是否相等 | |
*/ | |
public static function judgeArrayEquals($array1, $array2) | |
{ | |
if (!is_array($array1) || !is_array($array2)) { | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* brief: 格式化数据写入到文件中, 主要是写csv文件 | |
* | |
* @param $arrData //要写入是的数据。二位数组。[['title' => '标题1', 'title2' => '标题2']] | |
* @param $arrTitle //标题,一维数组。定义顺序。和数据的key一致。 | |
* @param $filepath //写入文件路径 | |
* @param $write_type //1: 保留原来数据,往后插入。 2: 保留原来数据,在头部写入. 注意,如果是文件头写入,是覆盖式写入,不是插入式。且从第一行开始. 这个时候就需要预先写入空行,且空行占用字节数应该大于等于要写入头部的字节数。否则会覆盖。 | |
* | |
* @return bool |
OlderNewer