PHP Archiv

Das PHP Script Verzeichnis

Tag Archives: Code

Diese Funktion holt eine zufällig ausgesuchte Datei auf einem vorgegebenen Ordner. function RandomFile($folder=“, $extensions=‘.*‘){ // fix path: $folder = trim($folder); $folder = ($folder == “) ? ‚./‘ : $folder; // check folder: if (!is_dir($folder)){ die(‚invalid folder given!‘); } // create files array $files = array(); // open directory if ($dir = @opendir($folder)){ // go trough […]

Automatisch einen abschliessenden Slash hinzufügen function add_ending_slash($path){ $slash_type = (strpos($path, ‚\‘)===0) ? ‚win‘ : ‚unix‘; $last_char = substr($path, strlen($path)-1, 1); if ($last_char != ‚/‘ and $last_char != ‚\‘) { // no slash: $path .= ($slash_type == ‚win‘) ? ‚\‘ : ‚/‘; } return $path; }[/php] Quelle: Jonas John

Eine Funktion, die an das Ende eines Pfades einen Slash setzt.Unterscheidet zwischen Windows und Unix Pfaden. function add_ending_slash($path){ $slash_type = (strpos($path, ‚\‘)===0) ? ‚win‘ : ‚unix‘; $last_char = substr($path, strlen($path)-1, 1); if ($last_char != ‚/‘ and $last_char != ‚\‘) { // no slash: $path .= ($slash_type == ‚win‘) ? ‚\‘ : ‚/‘; } return $path; […]

Den höchsten und den niedrichsten Wert ermitteln /* find the highest value */ print max(100, 70, 101, 50); // returns –> 101 $array = array(100, 701, 2, 4, 202); print max($array); // returns –> 701 /* find the lowest value */ print min(100, 70, 101, 50); // returns –> 50 $array = array(100, 701, 2, […]