Jump to content

Rename folder with php


discoloser

Recommended Posts

Hello,

 

I have a photo gallery with a simple ul list of categories.

The categories are folders on my server.

If a folder is named "Ödla" then the category is named "Ödla" too.

Is it possible to replace Ö in "Ödla" with o.

I onlyt want to change the name of the ul list, not the actual folder on the server.

 

I hope you understand what I mean.

Link to comment
Share on other sites

When you're echoing the list of folders, echo the url without using str_replace(), and the link with str_replace(). For example:

 

<?php
$folder_list = array( 'folder1', 'folder2', 'folder3' );
$needles = range( 1,3 );
$replacements = range( 'A','C' );
foreach( $folder_list as $v ) {
    echo "<a href=\"$v\">Link to " . str_replace($needles, $replacements, $v) . "</a><br>\n";
}
?>

 

The above returns this source:

<a href="folder1">Link to folderA</a><br>

<a href="folder2">Link to folderB</a><br>

<a href="folder3">Link to folderC</a><br>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.