473,749 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Folder Name Function

Hi group!

I have a code to process text, to make it url/folder fiendly. (code
below)
The only problem i have, is that the
$foldername = ereg_replace("[^[:alnum:] ]","",$foldernam e);
part deletes all spaces, but as you can see, i want spaces to become
underscores,
which are no ALNUM-chars.
How can i solve this?

Greetings Frizzle.

///// C O D E /////

$foldername = stripslashes ( $_POST['foldername'] );
//This erase white-spaces on the beginning and the end:
$foldername = preg_replace('~ ^(\s*)(.*?)(\s* )$~m', "\\2", $foldername);
// replace all weird chars
$special_chars =
array('À','Á',' Â','Ã','Ä','Å', 'Ç','È','É','Ê' ,'Ë','Ì','Í','Î ','Ï','Ñ','Ò',' Ó','Ô','Õ','Ö', 'Ù','Ú','Û','Ü' ,'Ý','à','á','â ','ã','ä','å',' ç','è','é','ê', 'ë','ì','í','î' ,'ï','ñ','ò','ó ','ô','õ','ö',' ù','ú','û','ü', 'ý','ÿ','C','c' ,'C','c');
$special_replac ements =
array('A','A',' A','A','A','A', 'C','E','E','E' ,'E','I','I','I ','I','N','O',' O','O','O','O', 'U','U','U','U' ,'Y','a','a','a ','a','a','a',' c','e','e','e', 'e','i','i','i' ,'i','n','o','o ','o','o','o',' u','u','u','u', 'y','y','C','c' ,'C','c');
$foldername = str_replace($sp ecial_chars, $special_replac ements,
$foldername);
//erases all NON-alfanumerics
$foldername = ereg_replace("[^[:alnum:] ]","",$foldernam e);
// take out repetative spaces:
$foldername = preg_replace('/\s\s+/', ' ', $foldername);
$foldername = preg_replace('/\s/', '_', $foldername);
$foldername = strtolower($fol dername);
if ($foldername == ""){$folder name = "untitled"; }

Oct 5 '05 #1
0 1195

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7206
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be created if they don't already exist, and if the drive happens to be one a folder cannot be created on (ie a cdrom drive) it would just be skipped without the code generating any errors. your help on this would be most appreciated. jenny
1
2610
by: Wayne | last post by:
I'm using the following code from the Access Web to open a folder. The folder opens in "List" View. Is there an addition that I can make to the code to force the folder to open in "Details" view? 'This code was originally written by Ken Getz. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. '
8
3984
by: Salad | last post by:
I designed a small app and I wanted to do a BrowseFolder (see http://www.mvps.org/access/api/api0002.htm), basically do a file open diaglog and select a directory/folder. The problem is that you can't specify the starting folder. Stephan Leban provided a neat solution that does allow me to browse using a starting folder. I am using A97 and it works fine. However, I put it onto a system that uses AccessXP. And it chokes on...
3
1999
by: Morten | last post by:
Hi! I'm trying to manage public folders using C#. I have found some code that allows me to mail enable a folder: foreach( System.Management.ManagementObject instmailbox in queryCollection ) { instmailbox = true; instmailbox.Put(); }
2
5046
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
1
1238
by: trialproduct2004 | last post by:
Hi all I am having one application where i want to implement new feature that is 'create new folder'. and display new folder name in listview. My listview is editable. My problem is i want to display unique folder name to the user at a time of creating new folder. That is if user click on 'create new folder' by default i am displaying text as 'New folder'. But i want this functionality to be same as that of windows explorer.
8
2579
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if the folder does not exsist, create folder "www" and then copy folder "temp" and its contents. If the folder "www" is there, look in it, check to see if the files in folder "temp" are in there, if not, copy the files that are not from folder...
9
3714
by: Nick 'The Database Guy' | last post by:
Hi All, I want to browse to a particular folder, not a particular file. The reason for this is that I have a utility that asks people to browse to a certain file, and I want them to be able to choose the location that they start browsing. Thanks in advance.
0
2316
parshupooja
by: parshupooja | last post by:
Contact Reply 1 point Member propoo Joined on 08-31-2007, 10:32 PM Posts 3 Hey all ,
3
4356
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right now the way I have this set up, but it's confusing and slow. When they browse for a place to save the reports, they see all of the drives on the terminal server as well as their own client drives. So they're likely to want to choose "My...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.