Jump to content
tooth-paste

Underscore added

Recommended Posts

I'am using the file field type. To output the name I use $file->name.

The problem is when I upload a file with a no breaking space, an underscore is added. 

Name of the file.pdf

Becomes

Name_of_the_file.pdf

How can I remove the underscore?

 

Share this post


Link to post
Share on other sites
$name = str_replace("_", "", $file->name);

 

  • Like 2

Share this post


Link to post
Share on other sites
6 minutes ago, Soma said:

$name = str_replace("_", "", $file->name);

 

Do you mean like this? It does not work.

$files = $pages->get("/portal/")->portal_file;
$name = str_replace("_", "", $file->name);
	foreach ($files as $file) {
		echo '<div class="row">
			<div class="col-md-12">
			<a href="'. $file->url .'">'. $name .'</a><br />
			</div>
			</div>';
}

 

Share this post


Link to post
Share on other sites

That replacement needs to be inside the foreach. You probably also want to replace with " " instead of ""

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...