В PHP у меня есть две строки:
$str1 = 'amare';
... и ...
$str2 = 'laudare';
Для $ str2 есть дополнительная форма, которая ...
$form2 = 'laudant';
Теперь я хотел бы сгенерировать $ form1 (для $ str1) в соответствии с изменением с $ str2 на $ form2:
laudare -> laudant =====> amare -> amant
Можете ли вы помочь мне создать функцию, которая это делает?
<?php
function generateForm($str1, $str2, $form2) {
// 1) get the shared part of $str2 and $form2: "lauda"
// 2) extract the according part for $str1: "ama"
// 3) get the ending which has been suffixed: "nt"
// 4) add the ending from step 3 to the base from step 2: "amant"
// 5) return the string from step 4
}
?>
Как можно реализовать это в PHP?Большое спасибо заранее!