Solved

String replacement on folders

Posted on 2014-02-25
1
191 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 dynamically set the form action using jQuery.

803 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