Groups | Search | Server Info | Login | Register


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

Ist hier noch jemand? str_replace multiple replacement

Path csiph.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Detlef Paschke <schabau@t-online.de>
Newsgroups de.comp.lang.php
Subject Ist hier noch jemand? str_replace multiple replacement
Date Mon, 4 Nov 2024 18:23:47 +0100
Message-ID <vgavv1$5s7v$1@solani.org> (permalink)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Mon, 4 Nov 2024 17:23:46 -0000 (UTC)
Injection-Info solani.org; logging-data="192767"; mail-complaints-to="abuse@news.solani.org"
User-Agent Betterbird (Windows)
Cancel-Lock sha1:lnZb7NDU0fIiVKkGqeODYn/Jksg=
X-User-ID eJwFwQcBwDAMAzBKTZ03ODkzfwiVDC4+oW6uRmMtT961aIRCf843DHPZzO5pCiXhQOLW0XooDhEz
Content-Language de-DE
Xref csiph.com de.comp.lang.php:4950

Show key headers only | 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