PHP Array, anahtar bir değere dayalı olsun

0 Cevap

Ben bu dizi varsa

$england = array(
        'AVN' => 'Avon',
        'BDF' => 'Bedfordshire',
        'BRK' => 'Berkshire',
        'BKM' => 'Buckinghamshire',
        'CAM' => 'Cambridgeshire',
        'CHS' => 'Cheshire'
);

Ben tam metin sürümü, nasıl ben aşağıdaki işlevi yazarsınız gelen üç harfli kodunu elde edebilmek istiyorum:

$text_input = 'Cambridgeshire';
function get_area_code($text_input){
    //cross reference array here
    //fish out the KEY, in this case 'CAM'
    return $area_code;
}

teşekkürler!

0 Cevap