Skip to content
Advertisement

PHP – strtr function with array not working

I am currently migrating a WordPress website to a new system I just created. I zipped the project and uploaded it to the server via WinSCP. A lot of the image filenames contain accents(e.g é) but didn’t retain the accents after unzipping.

For example Nestlé-Coffee-Mate-Chocolat-Crème-425g.jpg` became

Nestl#U00e9-Coffee-Mate-Chocolat-Cr#U00e8me-425g.jpg

on the server.

I am trying to write a script to read all the image files and rename them so that they get their accents back.

Based off this solution, I am trying something like this:

JavaScript

For testing purposes I created a folder test and put only one file in it, but the var_dump after using strtr still returns

Nestl#U00e9-Coffee-Mate-Chocolat-Cr#U00e8me-425g.jpg

Advertisement

Answer

strtr is case sensitive. Maybe this will help you.

Your array contains lowercase u’s, your file name uppercase ones.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement