Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

荒古 haxianhe

🎯
Focusing
Block or report user

Report or block haxianhe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@haxianhe
haxianhe / judgeArrayEquals.php
Last active Aug 5, 2019
判断两个数组是否相等
View judgeArrayEquals.php
<? php
/*
* 判断两个数组是否相等
*/
public static function judgeArrayEquals($array1, $array2)
{
if (!is_array($array1) || !is_array($array2)) {
return false;
}
@haxianhe
haxianhe / user_array_filter.php
Created Jul 12, 2019
php 过滤数组元素
View user_array_filter.php
<?php
$abnormalOrderIds = array_filter($abnormalOrderIds, function ($item) use ($completeOrders) {
return !isset($completeOrders[$item['code']]);
});
@haxianhe
haxianhe / array_group_by.php
Last active Jul 12, 2019
php数组按某一个元素值进行分组,正如数据库的group by语句
View array_group_by.php
<?php
/**
* 数组按某一个元素值进行分组,正如数据库的group by语句
* @param $array
* @param $key
* @return array
*/
public function array_group_by($array, $key)
{
@haxianhe
haxianhe / get_array_need.php
Last active Jul 12, 2019
php 过滤数组中有需要的键值对
View get_array_need.php
<?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'));
@haxianhe
haxianhe / unique_array_more.php
Last active Jul 12, 2019
php 二维数组去掉重复值
View unique_array_more.php
<? php
/**
* 对二维数组去重
* @param $array2D
* @return array
*/
function unique_array_more($array2D)
{
foreach ($array2D[0] as $key => $value) {
@haxianhe
haxianhe / trait.php
Last active Jul 12, 2019
PHP 用trait实现的单例
View trait.php
<?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();
}
@haxianhe
haxianhe / find_key_value.php
Created Jul 25, 2018
查找数组中上一个元素键/值,下一个元素键/值
View find_key_value.php
<?php
/*
* 查找数组中上一个元素键/值,下一个元素键/值
* @param str $currentValue 当前元素的值
* @param array $array 待查询数组
* @return array 上一个元素键/值,下一个元素键/值
*/
public function arrayPrevNext($currentValue, $array)
{
$prev_key = $next_key = null;
@haxianhe
haxianhe / sort.php
Last active Jul 12, 2019
PHP 对数据库结果排序(对多维数组排序)
View sort.php
<?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);
@haxianhe
haxianhe / aes_ecb_pkcs5.php
Created Jul 24, 2018 — forked from CodFrm/aes_ecb_pkcs5.php
PHP对接java的AES/ECB/PKCS5Padding加密方式
View aes_ecb_pkcs5.php
<?php
/**
*============================
* author:Farmer
* time:2017/12/19
* blog:blog.icodef.com
* function:加密方式
*============================
*/
You can’t perform that action at this time.