Skip to content

Instantly share code, notes, and snippets.

@yantze
Created July 18, 2015 07:17
Show Gist options
  • Save yantze/3bf79eb30b3fcace25a1 to your computer and use it in GitHub Desktop.
Save yantze/3bf79eb30b3fcace25a1 to your computer and use it in GitHub Desktop.
use array_key_exists and ArrayHelper switch a subArray
/**
* @return array of type
*/
public static function itemsAilas($type){
$items = [
'occupation'=> [
self::OCCUPATION_DOCTOR => 'แพทย์',
self::OCCUPATION_NURSE => 'พยาบาล',
self::OCCUPATION_PHARMACY => 'เภสัชกร',
self::OCCUPATION_DENTIST => 'ทันตแพทย์',
self::OCCUPATION_HEALTH => 'นักวิชาการสาธารณะ',
self::OCCUPATION_OTHER => 'อื่นๆ '
],
'office'=>[
self::OFFICE_PRIVATE => 'ภายใน รพ.ขอนแก่น',
self::OFFICE_PUBLIC => 'ภายนอก'
],
'choice'=>[
self::CHOICE_ONE => 'น้อยที่สุด',
self::CHOICE_TWO => 'น้อย',
self::CHOICE_THREE => 'ปานกลาง',
self::CHOICE_FOUR => 'มาก',
self::CHOICE_FIVE => 'มากที่สุด'
],
'type'=>[
self::TYPE_CONTENT => 1,
self::TYPE_CONTEST => 2,
self::TYPE_SEMINAR => 3,
self::TYPE_ICT => 4,
self::TYPE_FOOD => 5,
self::TYPE_NEWS => 6,
self::TYPE_REGISTER => 7,
self::TYPE_ENVIRONMENT => 8,
self::TYPE_AUDIOVISUAL => 9,
self::TYPE_LOCATION => 10,
self::TYPE_OVER_ALL => 11
]
];
return array_key_exists($type, $items) ? ArrayHelper::getValue($items,$type) : [];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment