【发布时间】:2012-04-27 16:49:27
【问题描述】:
大家好,我有一个 PHP 数组,它来自一个带有 2 组数据的 rss 提要。标题和描述。
(数组打印示例,我想编辑数组中的所有描述项,而不仅仅是一个索引)
[2] => ('Remembrance','Release Date: Thursday 19th April 2012')
如何操作描述字符串以在“发布日期:”进入 mysql 表之前删除它?
这是我的另一个代码:
$rss = simplexml_load_file('rss.xml');
$title = $rss->xpath('//title'); //finding the title tags in the xml document and loading into variable
$description = $rss->xpath('//description');
$rows=array();
foreach($result as $title){
$rows[]="('".mysql_real_escape_string($title)."','".mysql_real_escape_string(array_shift($description))."')";
}
mysql_query("INSERT INTO Films (Film_Name, Film_Release) VALUES ".implode(',',$rows));
print_r($rows);
【问题讨论】:
-
数组从何而来?
-
来自 RSS 提要,使用完整代码更新