Forum Moderators: coopster

Message Too Old, No Replies

replacing underscores with a Space in output

how to do this?

         

seofan

2:06 pm on Sep 27, 2004 (gmt 0)

10+ Year Member



I have the following that capitalizes the Text Output for US state names:

<?php
$str = $state;
$str = strtoupper($str);
echo $str; // Prints State in CAPITALS
?>

How do I add a "replace" to this to also replace the underscores in the states such as south_dakota, north_dakota, etc?

Thanks

lorax

2:09 pm on Sep 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you need is str_replace [us2.php.net].

Birdman

2:17 pm on Sep 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

pretty simple actually, you use str_replace() [php.net]

$str = str_replace('_', ' ', strtoupper($str));

Birdman

quick, Lorax! :)

seofan

2:40 pm on Sep 27, 2004 (gmt 0)

10+ Year Member



Thanks Lorax and Birdman - worked like a charm of course. I'm trying to get better at this. PHP isn't my particular forte - but my programmers are extremely busy and I'm trying to "help" on smaller projects - lol. Once I saw it I understood it, so at least that is a step forward. Thanks again.

lorax

3:41 pm on Sep 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> and I'm trying to "help"

I charge my clients twice as much when they try to help. ;)