PHP Usefull Functions

Usefull Functions

<?
function oddeven($number) {
  if ($number % 2 == 0) return 0;
  else return 1;
}
function rbg2html($color) {
  $p = explode(".", $color);
  for ($i=0; $i<count($p); $i++) $z = "$z".dechex($p[$i]);
  return $z;
}
function trans($text) {
  $cyr = "à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ú ÿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ú ß ÷ × ø Ø ù Ù þ Þ ÿ ß";
  $eng = "a b v g d e j z i i k l m n o p r s t u f h c u q A B V G D E J Z I I K L M N O P R S T U F H C U Q ch CH sh SH sht SHT iu IU q Q";
  $b = explode(" ",$cyr);
  $c = explode(" ",$eng);
  for($i=0 ;$i<=count($b) ; $i++) { $text = str_replace($b[$i],$c[$i],$text); }
  return $text;
}
function randnum() { $n = explode(" ",microtime()); return substr(rand(1,$n[1]), 0, 8); }
function randnum2() { return substr(md5(microtime()),0,8); }
function randnum3() { return substr(md5(rand(1,9999999)),0,8); }
function randquote($file) { $r = rand(0,count(file($file))-1); $a = file($file); return $a[$r]; }
function randgen() { for($i=0; $i<=3; $i++) $str = chr(rand(ord('a'),ord('z'))).rand(1,9).$str; return $str; }
function wifile($file,$what) {
  $open = fopen($file, 'a');
  fwrite($open,$what);
  fclose($open);
}
function trans($string) {
  $string = eregi_replace("&", "&amp;", $string);
  $string = eregi_replace("<", "&lt;", $string);
  $string = eregi_replace(">", "&gt;", $string);
  $string = eregi_replace(" ", "&nbsp;", $string);
  return $string;
}
function jstohtml($text) {
  $text = eregi_replace('"', "&#39;", $text);
  $text = eregi_replace("'", "&#34;", $text);
  echo "<script type=\"text/javascript\"> document.write('$text'); </script>";
}
function remdir($dir) {
  $handle = opendir($dir);
  while($file = readdir($handle)) {
    if ($file != "." && $file != "..")
    if (is_file("$dir/$file")) { unlink("$dir/$file"); }
    else { remdir("$dir/$file"); unlink("$dir/$file"); }
  }
}
function toten($n,$to) { while (($n % $to) != "0") $n = $n+1; return $n; }
?>