Skip to content

Instantly share code, notes, and snippets.

@haxianhe
Last active July 12, 2019 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haxianhe/e69be41f9399e21b9b12ae8bbe7e2417 to your computer and use it in GitHub Desktop.
Save haxianhe/e69be41f9399e21b9b12ae8bbe7e2417 to your computer and use it in GitHub Desktop.
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'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment