Solved

String replacement on folders

Posted on 2014-02-25
1
190 Views
Last Modified: 2014-02-25
Hello, I have this that strips out unwanted characters in files and displays the version without the characters on the screen. I'm needing to do the same thing with the folders that I'm displaying. I need to do this because Joomla does not like spaces in the folder names but because of that when I show the folder its all one word. For example, if the name of the folder is Faux Woods Joomla will not allow the admin to put files in but if i have it as FauxWoods it works fine. What I would like to do is have the folder name be Faux_Woods and then strip out the _ when displaying the folder to the screen. Below is the code that is currently being used to strip out characters from files


foreach($files as $file) {
			chdir ($rootDir);
			if (is_dir("$file")){
				echo '<li class="folder"><div class="heading">'.$file.'</div>';
				getDirectory("$path/$file",($level+1));
				echo '</li>';
			} else {
				$info = pathinfo($file);
				$fileNameOnly = basename($file,'.'.$info['extension']);
				$file = str_replace(array('&',','), array('%26','%2C'), $file);
				$fileNameOnly2 = str_replace(array('_','&'), array(' ','&amp;'), $fileNameOnly);
				if (strpos($path, '/secure/') == FALSE)
					echo '<li class="file"><a href="/images/'.$path.'/'.$file.'" target="_blank">'.$fileNameOnly2.'</a></li>';
				else
					echo '<li class="file"><a href="/index.php?option=com_imagedownload&file=/images/'.$path.'/'.$file.'" target="_blank">'.$fileNameOnly2.'</a></li>';
			}
		}
		echo '</ul>';
	} else {
		echo '<ul><li class="noDownloads">No Downloads Available.</li></ul>';
	}
}

Open in new window

0
Comment
Question by:DancingFighterG
1 Comment
 

Accepted Solution

by:
DancingFighterG earned 0 total points
ID: 39886545
Ok, I figured it out. Thanks anyway
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now