function unique_image ($string
{
$size=200;
$steps=5;
$step$size$steps
$image = image_create_alpha$size, $size);
$n = 0;
$prev = 0;
$len = strlen$string);
$sum = 0;
for ($i=0;$i$len$i++) $sum += ord$string$i]);
for ($i=0;$i$steps$i++) {
for ($j=0;$j$steps$j++) {
$letter = $string$n++ % $len];
$u = ($n % (ord$letter)+$sum)) + ($prev % (ord$letter)+$len)) + (($sum-1) % ord$letter));
$color = imagecolorallocate$image, pow$u$prev$u$prev+5,2)%256, pow$u$prev$u$prev+3,2)%256, pow$u$prev$u$prev+1,2)%256);
if (($u%2)==0)
imagefilledpolygon$image, array$i$step, $j$step, $i$step$step, $j$step, $i$step, $j$step$step), 3, $color);
$prev = $u
$u = ($n % (ord$letter)+$len)) + ($prev % (ord$letter)+$sum)) + (($sum-1) % ord$letter));
if (($u%2)==0)
imagefilledpolygon$image, array$i$step, $j$step$step, $i$step$step, $j$step$step, $i$step$step, $j$step), 3, $color);
$prev = $u
}
}
return $image
}
Tag: Roller
eXorithm – Execute Algorithm: View / Run Algorithm volume_cube
function volume_cube ($width$height$depth
{
return ($width * $depth * $height);
}
eXorithm – Execute Algorithm: View / Run Algorithm date_difference
function date_difference ($date1, $date2
{
  $seconds = abs$date2$date1);
  $text = ""
 Â
  $weeks = floor$seconds/(7*24*60*60));
  if ($weeks>0) $text .= "$weeks weeks, "
  $seconds = $seconds - ($weeks * 7*24*60*60);
 Â
  $days = floor$seconds/(24*60*60));
  if ($days>0) $text .= "$days days, "
  $seconds = $seconds - ($days * 24*60*60);
 Â
  $hours = floor$seconds/(60*60));
  if ($hours>0) $text .= "$hours hours, "
  $seconds = $seconds - ($hours * 60*60);
 Â
  $minutes = floor$seconds/(60));
  if ($minutes>0) $text .= "$minutes minutes, "
  $seconds = $seconds - ($minutes *60);
 Â
  $text .= "$seconds seconds"
   Â
  return $text
}Â
eXorithm – Execute Algorithm: View / Run Algorithm validate_phone
function validate_phone ($number
{
$number = preg_replace"/[().- ]/", '', $number);
$valid = "/^1?[2-9][0-9]{2}[2-9][0-9]{2}[0-9]{4}$/"
if ( preg_match( $valid, $number ) == 1 ) {
return true;
} else {
return false;
}
}
eXorithm – Execute Algorithm: View / Run Algorithm tag_cloud
function tag_cloud ($tags, $min_size, $max_size, $link, $link_class
{
$min = minarray_values$tags));
$max = maxarray_values$tags));
$spread = $max - $min
$cloud = ''
if ($link_class != '') $link_class = "class="$link_class" "
if ($spread == 0) $spread = 1;
foreach$tags as $tag => $count) {
$size = $min_size + ($count - $min) * ($max_size - $min_size) / $spread
$cloud .= '<a style="font-size:'floor$size).'px" '$link_class
.'href="'$linkurlencode$tag).'">'$tag"</a>n"
}
return $cloud
}
eXorithm – Execute Algorithm: View / Run Algorithm text_cloud
function text_cloud ($text, $num
{
$words = word_counts$text);
arsort$words);
$words = array_splice$words, 0, $num);
ksort$words);
return tag_cloud$words);
}
eXorithm – Execute Algorithm: View / Run Algorithm volume_prolate_spheroid
function volume_prolate_spheroid ($polar_radius$equatorial_radius
{
$volume = (4/3) * pi() * ($equatorial_radius * $equatorial_radius) * $polar_radius
return $volume
}
eXorithm – Execute Algorithm: View / Run Algorithm volume_sphere
function volume_sphere ($radius
{
return (4/3) * pi() * pow$radius,3);
}
eXorithm – Execute Algorithm: View / Run Algorithm soundex
function soundex ($word
{
$letters = 'abcdefgijklmnopqrstuvxyz'
$codes = '012301202245501262301202'
$word = strtolower$word);
$soundex = ''
$count = 0;
for ($ii=0; $iistrlen$word); $ii++) {
$letter = $word$ii];
$p = strpos$letters, $letter);
if ($p!==false) {
if ($codes$p]!==substr$soundex,-1)) {
$soundex .= $codes$p];
if ($codes$p]!='0') $count++; //count only consonants
if ($count>=5) break; //if we have 5 characters we're sure we can break
}
}
}
// add initial letter
$init = substr$word, 0, 1);
$p = strpos$letters, $init);
if ($p===false)
$soundex = strtoupper$init).$soundex
else
$soundex = strtoupper$init).substr$soundex, 1);
// get rid of the vowels
$soundex = str_replace'0', '', $soundex);
// trim or pad
if (strlen$soundex)>=4) {
$soundex = substr$soundex, 0, 4);
} else {
$soundex .= str_repeat'0', 4-strlen$soundex));
}
return $soundex
}
eXorithm – Execute Algorithm: View / Run Algorithm word_counts
function word_counts ($text, $noise
{
$words = preg_split'/[^A-Za-z]+/', strtolower$text));
$counts = array();
foreach ($words as $word) {
if (strlen$word)>1) { // 1-letter words are ignored
if (array_search$word, $noise)===false) { // noise word?
if (array_key_exists$word, $counts)) {
$counts$word] = $counts$word]+1;
} else {
$counts$word] = 1;
}
}
}
}
return $counts
}