Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel></channel>');
  2.  
  3. foreach($countries as $iso => $country) {
  4.  
  5.     $country_for_url = preg_replace( "/&([a-z])[a-z]+;/i", "$1", htmlentities( str_replace( ' ', '-', str_replace( "’", ' ', strtolower( $country ) ) ) ) );
  6.  
  7.     $item = $xml->addChild('item');
  8.     $item->addChild('title', $country);
  9.     $item->addChild('link', "https://davidelionetti.com/serveilvisto/per/$country_for_url/");
  10.     $item->addChild('language', 'it_IT');
  11.     $item->addChild('post_type', '<![CDATA[country]]>');
  12.     $item->addChild('post_name', $country);
  13.     $post_meta = $item->addChild('postmeta');
  14.     $post_meta->addChild('meta_key','<![CDATA[Country]]>');
  15.     $post_meta->addChild('meta_value',"<![CDATA['.$iso.']]>");
  16.     $item->addChild('status', '<![CDATA[publish]]>');
  17.  
  18. }
  19.  
  20. Header('Content-type: text/xml');
  21. $file = $xml->asXML();
  22. print $file;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement