Assign multiple keys to same value in array

后端 未结 3 1749
轮回少年
轮回少年 2021-02-03 09:59
 $lang = array(
        \'thank you\'=>\'You are welcome\',
        \'thanks\'=>\'You are welcome\',
        \'thank ya\'=>\'You are welcome\'
    );

3条回答
  •  悲&欢浪女
    2021-02-03 10:43

    You can use array_fill_keys() :

    $keys = array('thank you','thanks','thank ya');
    $lang = array_fill_keys($keys, 'You are welcome');
    

    Example

提交回复
热议问题