PHPで配列を取得しました:
$wxCode = array(
'VC' => 'nearby',
'MI' => 'shallow',
'PR' => 'partial',
'BC' => 'patches of',
'DR' => 'low drifting',
'BL' => 'blowing',
'SH' => 'showers',
'TS' => 'thunderstorm',
'FZ' => 'freezing',
'DZ' => 'drizzle',
'RA' => 'rain',
'SN' => 'snow',
'SG' => 'snow grains',
'IC' => 'ice crystals',
'PE' => 'ice pellets',
'GR' => 'hail',
'GS' => 'small hail', // and/or snow pellets
'UP' => 'unknown',
'BR' => 'mist',
'FG' => 'fog',
'FU' => 'smoke',
'VA' => 'volcanic ash',
'DU' => 'widespread dust',
'SA' => 'sand',
'HZ' => 'haze',
'PY' => 'spray',
'PO' => 'well-developed dust/sand whirls',
'SQ' => 'squalls',
'FC' => 'funnel cloud, tornado, or waterspout',
'SS' => 'sandstorm/duststorm');
ここにある場合は少しあります:
if (substr($part,0,1) == '-') {
$prefix = 'light ';
$part = substr($part,1);
}
elseif (substr($part,0,1) == '+') {
$prefix = 'heavy ';
$part = substr($part,1);
}
else $prefix = '';
ただし、配列と if: light rain に基づいて、次の文字列: -RA を次のテキストに変換する関数を書きたいと考えています。
どうすればいいですか?