Jump to content

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
https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/
Share on other sites

str_replace() should work for you. You can define an array of characters to be replaced and an array of characters that will do, errr,  the replacing (for lack of a better phrase).

 

I´ve tried str_replace(), but "odla" couldn´t find the images in "Ödla"

I´ll try to explain more clearly:

My image gallery is based on folders. Every folder is a category in the gallery.

If the folder´s name is "Öland" I want the url to be "oland".

Can I do this without changing the name of the folder and without using database?

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>

 

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.