<?php
$word = 'songsangkukah';
$word2 = $word;
if ( (substr($word,-3)=="kah") or (substr($word,-3)=="lah") or (substr($word,-3)=="pun") or (substr($word,-3)=="nya"))
{
$word2 = substr($word, 0 , -3);
}
if((substr($word2,-2)=="ku")or(substr($word2,-2)=="mu"))
{
$word2 = substr($word2 , 0 , -2);
}
echo $word2;
echo "<br />";
echo $word;
?>
Here you go. the required output.