<?php 
    function convert($keyword, $debug = false) {
       $wResult = preg_match_all('/I(?=[[:upper:]][[:lower:]])|A(?=[[:upper:]][[:lower:]])|[[:upper:]]{2,}|[[:upper:]][[:lower:]]*|[[:lower:]]+|\d+|#/u', $keyword, $matches);
       if($debug){
           var_dump($matches);
           var_dump($matches[0]);
           var_dump(implode(' ',$matches[0]));
       }
       return implode(' ',$matches[0]);
    }

    $originalCases = array(
        "comeHEREtomorrow" => "come HERE tomorrow"
        , "KissYouTODAY" => "Kiss You TODAY"
        , "comeÜndeHere" => "come Ünde Here"
        , "NEVERSAYIT" => "NEVERSAYIT"
        , "2013willCome" => "2013 will Come"
        , "Before2013ends" => "Before 2013 ends"
        , "IKnowThat" => "I Know That"
        , "#whatiknow" => "# whatiknow"
    );
    $newCases = array(
        "Icons" => "Icons"
        , "WellIKnowThat" => "Well I Know That"
        , "ITan" => "I Tan"
        , "whirlwind" => "whirlwind"
        , 'IWantABoat' => 'I Want A Boat'
    );
    
    function testConversion($str, $target, $n){
        $result = convert($str);
        printf('Case %2d is %s:  %24s => %-24s ("%s" expected)'."\n"
            , $n
            , strcmp($target, $result)?"  FAILED  ":"SUCCESSFUL"
            , "\"$str\""
            , "\"$result\""
            , $target
        );
    }
    echo "Initial Cases:\n";
    $n = 1;
    foreach ($originalCases as $str => $target) {
        testConversion($str, $target, $n++);
    }



    echo "\n\nNew Cases:\n";
    foreach ($newCases as $str => $target) {
        testConversion($str, $target, $n++);
    }
?>