Problem transforming key/word in admin plugin

Hi, I made an admin plugin storing some key/word options. The code is using it for a file modify & transfer from one server to another. Globally it works correctly, transferring with rsync and modifying with sed. (I thing I will push it to GIT if anyone is interested)
But I still have a problem that seems to be a contextual variable used and I don’t understand how to bypass it.

When performing the action, the plugin
1 gets back the option (working)
$keywords = $this->pluginConfig->get('plugins.pagetransfer.avantapres') ?? [];
2 looping in
foreach ($keywords as $pair) {
3 at this step I need to replace caracters in (“/” must be “/”) so I tried with
$escapedKey=str_replace('/', '\\/', $pair['key']);
(also tryed with reg_replace, preg_replace…)
The result is no result ! Nothing changes. if $pair[‘key’] is equal to “http://www.google.com”, $escapedKey is equal the same without any change.

After turning crazy, I tryed
$escapedKey=str_replace('/', '\\/', http://www.google.com);
and the result is good => http:\/\/www.google.com

Then as I think it may be contextual to all Grav layers, how can I overcome this behavior ?

So this works:

$escapedKey=str_replace('/', '\\/', http://www.google.com);

And this doesn’t?

$escapedKey=str_replace('/', '\\/', $pair['key']);

Debug what you get as the $pair['key']

perfect summary.

$pair['key'] ="http://www.google.com"

ok a little more.
str_replace seems to work with changing something else than “/”.
example :
based on $pair['key'] ="http://www.google.com"

if I go for $modify=str_replace('h', '\\/', $pair['key']);
I will have \/ttps:\\www.google.com

(and to answer the deleted post from @b.da , I’m using php 8.3)

Either something is missing in your research or / symbols are different in $pair['key']. For example, all of these are different from each other:

/
∕
̸
/
̷
⁄

you were damn right ! so stupid I am ! :scream: I don’t know how I got those strange differents slash but that’s it.
Thanks :grinning: