Werbung

Werbung

Werbung

Archive

Folge uns auf Twitter

Werbung

Jede Menge neue Twitter Follower bekommen. Die Software hat einen kostenlosen Trial Mode, der bis zu 250 Follower bringt.

Willkommen

Willkommen im PHP Archiv Blog! Hier gibts Infos zum Thema PHP Codeschnipsel und Tipps. Bei unserem Projekt phparchiv.de, finden Sie über 5700 Scripte.

Slash

Einen Schrägstrich hinzufügen

Diese kleine Routine fügt am Ende eines Pfades einen Slash hinzu.

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]

Automatische einen Abschluss Slash hinzufügen

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

An das Ende eines Pfades automatisch einen Slash setzten

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;
}[/php]
Quelle: jonasjohn.de