is there any better way then this for chracter replacement in string?

brahimbb

New Member
I am working on my url to make it pretty. and here is the logic i came up with. now in the url i want to achieve something like this.http://domain.com/category/date/post-titlefor that i first populated the value from the database, i.e date and the post title like this for date: \[code\]$date = date("d", $row['timestamp']);$month = date("m", $row['timestamp']);$year = date("Y", $row['timestamp']);$date_url = $date.$month.$year;\[/code\]for title: \[code\]$title = $row['title'];$title_url = str_replace(" ", "-", $title);\[/code\]now i created a hyperlink to send it to URL like this.\[code\]<a href="http://stackoverflow.com/questions/3624785/news.php?id=<?php echo $id; ?>&cat=<?php echo'news'; ?>&date=<?php echo $date_url; ?>&title=<?php echo $title_url; ?>"><img src="http://stackoverflow.com/questions/3624785/<?php echo'admin-login/'.$pic_title; ?>"/></a>\[/code\]my main concern is the title, which i am populating the value from the database, is it ok to use \[code\]str_replace()\[/code\] for this? or is there any better way?do i go wrong anywhere or it is fine to go ahead with this logic?thank you..
 
Back
Top