All pastes #536500 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-04 12:30 UTC
rendered paste body
<?php
/**
 * 
 */

$s = 'this :D is !@#$% an example of a sentence containing -=_+ some relatively      long words and it has a few miscellaneous characters in it too.';

$w = array();
$l = strlen($s);
$c = 0;
for ($i=0; $i<$l; $i++) {
	if ($i>1 && ($s[$i-1]!=' ' && $s[$i]==' ') || ($s[$i-1]==' ' && $s[$i]!=' ') ) {
		if (strlen($w[$c])>4) // Can be >3, but >4 looks better imo
			$w[$c] = $w[$c][0] . str_shuffle( substr($w[$c], 1, -1) ) . substr($w[$c], -1);
		$c++;
	}
	if (!isset($w[$c]))	$w[$c] = '';
		$w[$c] .= $s[$i];
}

var_dump($w);

?>