All pastes #109070 Raw Edit

Shuffle words

public php v1 · immutable
#109070 ·published 2006-07-31 20:45 UTC
rendered paste body
#! /usr/bin/php<?phpdefine('DEBUG',false);$ponctuation = ',;:?.=+-_)(|@#"\'!°[]*%/\\';for($i=0;$i<strlen($ponctuation)-1;$i++) { $pa[]=$ponctuation{$i}; }unset($argv[0],$tmp,$i);if (strpos($argv[1],' ')!==false) { $argv=explode(' ',$argv[1]);}foreach($argv as $k=>$v) {	$len = strlen($v);	$v = utf8_decode($v);	$mots[$k] = '';	$tmc='';	if (DEBUG===true)		echo $v." [len: ".$len."]\n";		for($i=0;$i<$len;$i++) {		if (!in_array($v{$i},$pa) && $i!=$len-1) {			$tmc.= $v{$i};			$dbg[]='1';			continue;		}		if ($i==$len-1 && (strlen($tmc)+1)<=3) {			$mots[$k].=$tmc.$v{$i}.(DEBUG===true?'[2]':'');			$tmc='';			continue;		}				if ((in_array($v{$i},$pa) || $i==$len-1) && (strlen($tmc)+1)>=4) {			$first = $tmc{0};			$mots[$k].= $first.str_shuffle(substr($tmc,1,strlen($tmc)-1)).$last.$v{$i}.(DEBUG===true?'[3]':'');			$tmc='';			continue;		}		if (in_array($v{$i},$pa) && strlen($tmc)<=3) {			$mots[$k].= $tmc.$v{$i}.(DEBUG===true?'[3]':'');			$tmc='';			continue;		}		$tmc.= $v{$i};	}	$mots[$k].=$tmc.(DEBUG===true?'[1]':'');}echo utf8_encode(implode(' ',$mots)),"\n";?>