我在PHP中解析RSS问题。我需要在RSS中更改一些标签,并根据另一个网站提供的模式为某些数据分配值。我设法使用array_map将国家名称更改为ISO,但是当我尝试将该函数重用于另一个值时,它无效。我为每个数组使用不同的.csv文件。
任何想法?
示例:
[CODE]:
$field_country = substr($field_country, strrpos($field_country, "|")+1);
$field_city = $feed[$x]['field_city'];
$field_job_type = $feed[$x]['field_job_type'];
$category = $feed[$x]['category'];
$category = split('[|,]', $category);
$field_job_experience = $feed[$x]['category'];
$field_job_experience = substr($field_job_experience, strrpos($field_job_experience, "Job Level|")+10);
$job_number = $feed[$x]['job_number'];
$pubDate = date('c', strtotime($feed[$x]['pubDate']));
$closeDate = date('c', strtotime($feed[$x]['closeDate']));
echo '<title>'.$title.'</title>';
echo '<pubDate>'.$pubDate.'</pubDate>';
echo '<field_job_closing_date>'.$closeDate.'</field_job_closing_date>';
$csv = array_map('str_getcsv', file('countries.csv'));
$findName= $field_country;
foreach($csv as $values)
{
if($values[1]==$findName)
echo '<field_country>' .$values[2]. '</field_country>';
};
echo '<field_city>'.$field_city.'</field_city>';
$csv = array_map('str_getcsv', file('job_category.csv'));
$findName= $field_job_type;
foreach($csv as $values)
{
if($values[0]==$findName)
echo '<field_job_type>' .$values[1]. '</field_job_type>';
};
echo '<field_career_categories>'.$category[1].'</field_career_categories>';
echo '<field_job_experience>'.$field_job_experience.'</field_job_experience>';
echo '<field_source>1979</field_source>';
echo '<field_theme></field_theme>';
echo '</item>';
}
echo '</channel></rss></xml>';