All pastes #907471 Raw Edit

sskaje

public php v1 · immutable
·published 2008-02-17 17:09 UTC
rendered paste body
<?php$string = <<<STRINGdlcedus  zweere  shtnoou  ttsunde  frhies  ysftro  enprtoy  js1eam  lmekli  skyaprSTRING;$arrInput = preg_split('/\s+/', $string);$file = file('wordlist.txt');$wordlist = array_map('rtrim',$file);$result = array();foreach ($arrInput as $value){	foreach ($wordlist as $str)	{		if (shellsort($value)==shellsort($str))		{			array_push($result, $str);			break;		}	}}echo implode(',',$result);function shellsort($str){	$n = strlen($str);	for ($gap =(int) $n/2; $gap=(int)$gap, $gap>0; $gap /= 2)	{		for ($i = $gap; $i < $n; $i++)		{			for ($j = $i-$gap; $j>=0 && $str[$j]<$str[($j+$gap)]; $j -= $gap) 			{				$temp = $str[$j];				$str[$j] = $str[($j+$gap)];				$str[($j+$gap)] = $temp;			}		}	}	return $str;}?>