UPDATE 1:
This is how I am attempting to build the string:
header('Content-type:application/json');
function getdata($the_query)
{
$connection = mysql_connect('server', 'user', 'pass') or die (mysql_error());
$db = mysql_select_db('db_name', $connection) or die (mysql_error());
$results = mysql_query($the_query) or die(mysql_error());
$the_data = "{
\"rss\": {
\"channels\" : [
{
\"title\" : \"".$title."\",
\"link\": \"http://www.mycompany.com/external.php\",
\"description\": \"company description goes here\",";
while($row = mysql_fetch_array($results))
{
extract($row);
$the_data .= "\"items\" : [
{
\"title\": \"".$title."\",
\"link\": \"".$link."\",
\"guid\": \"".$link."\",
\"pubDate\": \"".$date."\",
\"description\": \"".$description."\"
} ],";
}
$the_data .= "} ]
}
}";
mysql_close($connection);
return $the_data;
}
ORIGINAL QUESTION:
I have a string similar to this:
$mystring = "{
\"rss\": {
\"channels\" : [
{
\"title" : \"title goes here\",
\"link": \"link goes here\",
\"description": \"description goes here\",
\"items\" : [
{
\"title\": \"title goes here\",
\"link\": \"url goes here\",
\"guid\": \"id goes here\",
\"pubDate\": \"data goes her\",
\"description\": \"description goes here\"
} ],
\"items\" : [
{
\"title\": \"title goes here\",
\"link\": \"url goes here\",
\"guid\": \"id goes here\",
\"pubDate\": \"data goes her\",
\"description\": \"description goes here\"
} ],
\"items\" : [
{
\"title\": \"title goes here\",
\"link\": \"url goes here\",
\"guid\": \"id goes here\",
\"pubDate\": \"data goes her\",
\"description\": \"description goes here\"
} ],
} ]
}
}";
How do I remove the last comma?