Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

array+ändern

Empfohlene Antworten

hi ich habe bei php ein array in dem alle files von einem verzeichnis stehen. wie kann ich jeze bei allesn dateien die endung wegnehmen??


for ($j = 0; $j < count($filelist); $j++){
$endung = split("[.]",$filelist[$j]);
echo $endung[0],";
};
[/PHP]

wenn ich es so mache listet er mir zwar alle dateinamen auf aber wie kann ich daraus wider ein neues array erstellen???

Ich bin zwar mehr der Perlmensch, aber dafuer langen meine PHP-Faehigkeiten noch. ;)

#!/usr/bin/php

<?
$old = array("datei.txt", "bild.jpg", "config.conf");
$new = array();

foreach ($old as $element)
{
array_push($new, preg_replace('/\..+$/', '', $element));
}

print_r($old);
print_r($new);
?>[/PHP]

% ./test.php

Array

(

[0] => datei.txt

[1] => bild.jpg

[2] => config.conf

)

Array

(

[0] => datei

[1] => bild

[2] => config

)

Gruss

iscariot

danke!! :) nur kann ich aus dem array dann auch so ein array machen?


$array = array("[bild1]" => "<img src=bild1.gif></img>", "[bild2]" => "<img src=bild2.gif></img>");
[/PHP]


<?
$old = array("bild1.jpg", "bild2.jpg", "bild3.jpg");
$new = array();

foreach ($old as $element)
{
$new[preg_replace('/\..+$/', '', $element)] = "<img src=\"".$element."\"></img>";
}

print_r($old);
print_r($new);
?>
[/PHP]

So sollte es gehen!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.