splitting multiple joined words, port from perl to PHP
This should be find_words() php equivalent,
(note perl %words is here $Gwords as perl makes distinction between hashes/dictionaries and arrays)

function find_words() {
    global $Gwords;

    # Print every way $string can be parsed into whole words
    $words = func_get_args();
    $string = array_shift($words);
    $length = strlen($string);

    foreach (range(1, $length) as $i) {

        $word = substr($string, 0, $i);
        $remainder = substr($string, $i, $length - $i);
        # Some dictionaries contain each letter as a word
        if ($i == 1 &amp;&amp; ($word !== "a" &amp;&amp; $word !== "i")) continue;

        if (isset($Gwords[$word])) {
            $words[]= $word;
            if ($remainder === "") {
                echo join(' ', $words), "\n";
                return;
            }
            else {
                # find_words($remainder, @words);
                call_user_func_array(
                    "find_words",
                    array_merge((array)$remainder, $words)
                );
            }
            array_pop($words);
        }
    }

    return;
}