Hello!
I want to create links to RSS posts, but I need a ‘slug’. I want to replace the whitespaces with a “-”, so I can redirect the links to my posts on my wordpress site. My RSS: http://modules.publiceer.net/nieuwsfeed_webgiants2012.php
[php]<?php
include(“connect.inc.php”);
$items = mysql_query(“select * from dailynewsitems where actief = ‘1’ and pubDate <= NOW() order by id DESC limit 15”);
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>
<rss version=“2.0” xmlns:atom=“http://www.w3.org/2005/Atom”>
Nieuwsfeed WebGiants Financieel
Nieuwsfeed WebGiants
http://modules.publiceer.net/nieuwsfeed_webgiants2012.php
nl";
while ($item = mysql_fetch_object($items)) {
$id = $item->id;
$title = $item->title;
$description = $item->description;
$longdesc = $item->longdesc;
list($d, $m, $y) = explode("-", $item->pubDate);
echo '<item>';
echo '<guid>' . $item->id . '</guid>';
echo '<title>' . htmlspecialchars($title) . '</title>';
echo 'DATUM<pubDate>' . date("D", mktime(0, 0, 0, $m, $d, $y)) . ', ' . $d . ' ' . date("M", strtotime($item->pubDate)) . ' ' . $y . ' 00:00:00 CST</pubDate>';
echo '<description>' . htmlspecialchars($description) . '</description>';
echo '<longdesc>' . htmlspecialchars($longdesc) . '</longdesc>';
echo "<link>http://www.webgiants.nl/geen-categorie/".$item->title."</link>";
echo '</item>';
}
echo “”;
echo “”;[/php]
I did some research and know you can do it with something like this: $title = preg_replace("/[\s-]+/", " ", $title);
But I dont know how to implement this in my code.
Thanks in advance!