Acronym + Last Word of the Entered Text. PHP
<p>nickb originally provided these codes. What this originally does is that, when a user enters a text, it will convert it into a acronym by getting the first letters of every word entered. What I want to do now is to include the Last word of the text entered as part of the output. Example: if the user enters Automated Teller Machine, then the output would be: ATM Machine. So far, this is what I came up, unfortunately, I am at a loss right now and is desperate to get this working. Please help.</p>

<pre><code>function convert($text) 
{
    $acronym = array();
    $text2 = explode(' ', $text);
    foreach(explode( ' ', $text) as $word)
    {                   
        $acronym[] = strtoupper( $word[0]);
    }
    $count = str_word_count($acronym); 
    array_push($acronym, $text2[$count]);
    echo $text2[$count];
    return implode('', $acronym);
}
</code></pre>
