discoloser Posted October 13, 2010 Share Posted October 13, 2010 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 More sharing options...
discoloser Posted October 13, 2010 Author Share Posted October 13, 2010 And I don´t want to use mysql... Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121759 Share on other sites More sharing options...
Pikachu2000 Posted October 13, 2010 Share Posted October 13, 2010 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). Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121774 Share on other sites More sharing options...
discoloser Posted October 13, 2010 Author Share Posted October 13, 2010 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" Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121778 Share on other sites More sharing options...
Pikachu2000 Posted October 13, 2010 Share Posted October 13, 2010 Images? Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121782 Share on other sites More sharing options...
discoloser Posted October 13, 2010 Author Share Posted October 13, 2010 Yes, I have images in the category folders on my server. And when I use str_replace to change Ödla to odla, the category can´t find the images Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121784 Share on other sites More sharing options...
Pikachu2000 Posted October 13, 2010 Share Posted October 13, 2010 Oh, no. I mean use str_replace() to echo the folder names to the screen, not to specify the folder name in the path . . . Can you post the relevant section of code? Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1121785 Share on other sites More sharing options...
discoloser Posted October 15, 2010 Author Share Posted October 15, 2010 Can I use str_replace() to specify the folder name in the path? Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122397 Share on other sites More sharing options...
chintansshah Posted October 15, 2010 Share Posted October 15, 2010 can you post your code for better understanding of your problem. Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122432 Share on other sites More sharing options...
discoloser Posted October 15, 2010 Author Share Posted October 15, 2010 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? Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122446 Share on other sites More sharing options...
salathe Posted October 15, 2010 Share Posted October 15, 2010 How will your script know that oland maps to the Öland folder? Solving that problem seems to be the main sticking point. Do the folders change very often? Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122463 Share on other sites More sharing options...
Pikachu2000 Posted October 15, 2010 Share Posted October 15, 2010 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 https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122469 Share on other sites More sharing options...
discoloser Posted October 15, 2010 Author Share Posted October 15, 2010 How will your script know that oland maps to the Öland folder? Solving that problem seems to be the main sticking point. Do the folders change very often? Exactly, there is a problem. The folders will not change, but I will be adding new ones. Link to comment https://forums.phpfreaks.com/topic/215777-rename-folder-with-php/#findComment-1122486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.