How do you change link text with PHP?<

windows

Guest
I'm building a website with over 3000 index.php pages and within these pages, are a listing of links that all look like this for example:

rolling_stones-paint_it_black (<!-- m --><a class="postlink" href="http://www.mydomain.com/r/rolling_stones/rolling_stones-paint_it_black.php">http://www.mydomain.com/r/rolling_stone ... _black.php</a><!-- m -->)
led_zeppelin-kashmir (<!-- m --><a class="postlink" href="http://www.mydomain.com/l/led_zeppelin/led_zeppelin-kashmir.php">http://www.mydomain.com/l/led_zeppelin/ ... ashmir.php</a><!-- m -->)
pink_floyd-comfortably_numb (<!-- m --><a class="postlink" href="http://www.mydomain.com/p/pink_floyd/pink_floyd-comfortably_numb.php">http://www.mydomain.com/p/pink_floyd/pi ... y_numb.php</a><!-- m -->)

Notice how artist/band is seperated by song with the " - ".

What'd I'd like the links to say, using the examples above, are just "Paint It Black Tab", "Kashmir Tab" and "Comfortably Numb" Tab, so it would have to somehow cut off, or not display artist/band for every link, capitalize the beginning of every word, change the _'s to spaces, and add the word "Tab" after ever link.

These links are allready pre-generated and embedded into the index.php pages, and there's no way I can make them generate anything other than like the example links above.

Does anyone know how to do this? Is it even possible?Well you can easily change the underscores and hyphens to spaces...
check out the explode function
<!-- w --><a class="postlink" href="http://www.php.net/explode">www.php.net/explode</a><!-- w -->

I believe there is a way to make each first letter capatalized, but I'm not sure. Try searching the manual.To capitalize the letters of every word in a string use the ucwords function.

ucwords($string)Why dont you just use the str_replace funtion to change underscores to spaces?
 
Back
Top