Codice PHP:
// C
int main(int argc, char *argv[]) {
char *str;
for(argc = 0; argc < 90; argc++) {
str = (char *)calloc(((argc < 10 ? 1 : 2) + 2), sizeof(char));
sprintf(str, " %i ", argc);
printf("%i\n", virtualSmorfia(str));
free(str);
}
return 0;
}
Codice PHP:
// JavaScript
function virtualSmorfia(str) {
str = str.replace(/^\s+|\s+$/g, "");
var a = 0, b = str.length; c = 0;
str = hex_md5(str);
while(a < 32)
c += str.charCodeAt(a++);
return Math.floor(c / b) % 90 || 90;
};
Codice PHP:
// Python
import md5
def virtualSmorfia(str):
str = str.strip()
a = 0; b = len(str); c = 0
str = md5.new(str).hexdigest()
while(a < 32):
c = c + ord(str[a]); a = a + 1
return ((int)(c / b) % 90) or 90
Codice PHP:
// PHP
function virtualSmorfia($str) {
$str = trim($str);
$a = 0; $b = strlen($str); $c = 0;
$str = md5($str);
while($a < 32)
$c += ord(substr($str, $a++, 1));
$c = (int)($c / $b) % 90;
return $c === 0 ? 90 : $c;
}
Codice PHP:
// ActionScript
function virtualSmorfia(str:String):Number {
str = trim(str);
var a:Number = 0, b:Number = str.length, c:Number = 0, m:md5 = new md5();
str = m.hash(str);
while(a < 32)
c += str.charCodeAt(a++);
return Math.floor(c / b) % 90 || 90;
}
come vedi l'highlight_string di PHP fa già quello che cerchi su una funzione built_in, molto veloce ... tutto quello che devi verificare è se il tag di apertura codice
<?php
è presente o meno nella stringa ... se non c'è lo metti all'inizio, fai l'highlight e poi lo rimuovi dalla stringa "highlightata" 
P.S. ovviamente Geshi è una cosa più professionale ma secondo me non così indispensabile, resta di fatto uno dei più noti e funzionali