Groups | Search | Server Info | Login | Register


Groups > de.comp.lang.php > #4950

Ist hier noch jemand? str_replace multiple replacement

From Detlef Paschke <schabau@t-online.de>
Newsgroups de.comp.lang.php
Subject Ist hier noch jemand? str_replace multiple replacement
Date 2024-11-04 18:23 +0100
Message-ID <vgavv1$5s7v$1@solani.org> (permalink)

Show all headers | View raw


Hallo an alle,

ist sehr ruhig geworden. Ich hoffe mal, dass hier noch jemand ließt.

Ich habe in einem Script eine Zeile, die zwei mal str_replace ausführt,
weil ich zu dumm bin, das in einem mal hinzubekommen.

str_replace(['../', './'], '', str_replace('\\', '/', $datei));

Mit preg_replace geht es so, wie ich es mir vorstelle, doch so kann ich
es kaum noch lesen.

preg_replace(['/(\.\/|\.\.\/)/', '/(\\\\)/'], ['', '/'], $datei);

Ich bekomme ein ODER im Suchausdruck mit str_replace einfach nicht hin
oder zumindest nicht so, dass ein Array im Ersetzen-Teil dann noch
zuverlässig funktioniert.
So funktioniert es zwar, aber schön ist das auch nicht.

str_replace(['./', '../', '\\'], ['','','/'], $datei)

Ist noch einer von den Profis hier, die genau wissen, wo wieder mal eine
Klammer fehlt oder das Hochkomma falsch ist?

Viele Grüße
Detlef Paschke

-- 
Das "Zitat des Augenblick" gibt es nur auf:
https://schabau.eu

Meine "Merkzettel" findet man unter:
https://helpdesk.schabau.eu

Back to de.comp.lang.php | Previous | NextNext in thread | Find similar


Thread

Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-04 18:23 +0100
  Re: Ist hier noch jemand? str_replace multiple replacement Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2024-11-04 22:56 +0000
    Re: Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-05 10:03 +0100
      Re: Ist hier noch jemand? str_replace multiple replacement Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2024-11-05 09:59 +0000
        Re: Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-05 12:38 +0100
          Re: Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-05 12:55 +0100
          Re: Ist hier noch jemand? str_replace multiple replacement Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2024-11-05 12:19 +0000
            Re: Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-05 15:27 +0100
  Re: Ist hier noch jemand? str_replace multiple replacement Arno Welzel <usenet@arnowelzel.de> - 2024-11-07 17:31 +0100
    Re: Ist hier noch jemand? str_replace multiple replacement Detlef Paschke <schabau@t-online.de> - 2024-11-08 11:25 +0100
      Re: Ist hier noch jemand? str_replace multiple replacement Arno Welzel <usenet@arnowelzel.de> - 2024-11-08 17:29 +0100

csiph-web