Dynadot โ€” .com Registration $8.99

PHP Newb Needs Help w/ String Replace

Spaceship Spaceship
Watch

NickRac

Yes.VIP Member
Impact
35
Hey guys,

Here is my line of HTML and PHP:

http://pastebin.com/m22cb4b33

let's say key=Art_History

I want it to display "Art History" in the header.

what code do I need to add to this to accomplish it?

I appreciate and rep+ any help!

Nick
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
$key = str_replace("_", " ", $key);
 
0
•••
do I put that right before the echo?

Also I want it to apply this only to this specific line of code - I use "key" again later in the page and don't want to replace for that one.
 
0
•••
you could use str_replace("_", " ", $key); in the echo itself which would keep $key in tact.

If you use this more than once I would put it in a variable however.
 
0
•••
So essentially you will need to make sure all categories are spaced Like_This and nothing else for the categories otherwise it won't display right with just this code. If you're using it more than once try this:

PHP:
<h2><?php $cat = htmlentities(urldecode(str_replace("_"," ",$_GET['key']))); echo $cat."<br /><br />Some more text blah blah category: ".$cat; ?></h2>

-RageD
 
Last edited:
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back