Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

String replacement on folders

Posted on 2014-02-25
1
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

636 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