How to wrap first word of page title in span in drupal 7
Not really a Drupal question, but you're setting the wrong variable

$title = implode(' ', $words);


should be

$variables['title'] = implode(' ', $words);


Or, change

$title = $variables['title'];


to 

$title = &amp;$variables['title'];


instead. Either will work