我有一些这样的:
$fabrics = array (
'B' => 'BAWEŁNA',
'P' => 'POLIESTER',
'S' => 'SPANDEX',
'E' => 'ELASTAN',
'PO' => 'POLIAMID',
'EL' => 'ELASTAN',
'A' => 'AKRYL',
'AN' => 'ANGORA',
'NY' => 'NYLON',
'W' => 'WEŁNA',
'WO' => 'WEŁNA OWCZA',
'POL' => 'POLIWINYL',
'PVC' => 'PCV',
'SZJ' => 'SZTUCZNY JEDWAB',
'SK' => 'SKÓRA NATURALNA',
'POP' => 'POLIPROPYLEN'
);
$textiles = array( 'B 100%', 'B 80%, P 20%', 'NY 70%, EL 30%', 'B 75%, S 20%', 'SZJ 80%, E 20%');
// rand textilies
$textile = $textiles[array_rand($textiles)];
echo $textile.'</br>';
echo preg_replace(array_keys($fabrics), $fabrics, $textile);
我希望使用preg_replace来更改全名的密钥。但是它并没有发挥作用。:你能帮忙吗?
答案 0 :(得分:2)