Solved

String replacement on folders

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

724 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