php - SimplePie RSS not accepting variable with comma separated strings -
i'm trying use simplepies "$feed->set_feed_url (array());"
function having major difficulty understanding why wont accept values.
when add urls manually (i.e directly below), work fine. feeds go through ok , displays feeds needed.
$feed ->set_feed_url (array( 'http://www.theverge.com/tag/rss', 'http://feeds.ign.com/ign/all' ));
i have urls in database table pulling out normal while loop. append comma , remove trailing comma nice simplepie array. so:
while($row = mysqli_fetch_array($pullallaccountsdoit)){ $result4mdb .= $row[0] . ","; } $result4mdb = substr($result4mdb, 0, strlen($result4mdb) -1); echo "the result is: " . $result4mdb;
when this, , echo out "$result4mdb", prints out: the result is: http://www.gamespot.com/feeds/mashup/,http://www.theverge.com/tag/rss
meaning variable , printing out need. far good. go simplepie code, put in varialble so:
$feed ->set_feed_url (array($result4mdb));
and nothing happens. don't errors or anything, page stays blank , nothing comes up.
for testing, gettype($result4mdb);
, tells me variable "string" , again, output of variable when echoed urls got database know whole process far working.
for further testing, go database , remove 1 of urls when queried, returns 1 value, , of sudden simplepie works.
i've been searching day , half now, trying different things , googling as possible no avail. cant quite it.
i'm @ wits end. assistance why isn't working greatly appreciated.
thank in advance everyone
you're producing string containing comma seperated values. need array, explode()
string:
change:
$feed ->set_feed_url (array($result4mdb));
to
$feed ->set_feed_url (explode(',', $result4mdb));
more elegant version, change:
while($row = mysqli_fetch_array($pullallaccountsdoit)){ $result4mdb .= $row[0] . ","; }
to
while($row = mysqli_fetch_array($pullallaccountsdoit)){ $result4mdb[] = $row[0]; }
this way you're not creating string needs exploeded, create array @ first.
Comments
Post a Comment