Url ve diğer karakterlerin şerit dizisi show sadece ismi yayınlarız

0 Cevap php

The xml is like this: (wordpress url's) I want to strip them and get only the posts words. http://www.site1.com/dir/this-is-page/ http://www.site2.com/this-is-page

How do i strip the url's and get only "this is page" (without the rest of the urls, and the "-") if i have two diffrent types of urls; one with dir and one without dir? Sample code bellow:

$feeds = array('http://www.site1.com/dir/feed.xml', 'http://www.site2.com/feed.xml');

foreach($feeds as $feed) 
{ 
  $xml = simplexml_load_file($feed);

  foreach( $xml->url as $url )
 {     
    $loc = $url->loc; 
 echo $loc;
 $locstrip = explode("/",$loc);
 $locstripped = $locstrip[4]; 
 echo '<br />';

 echo $locstripped;

 echo '<br />';

 mysql_query("TRUNCATE TABLE interlinks");

 mysql_query("INSERT INTO interlinks (title, url) VALUES ('$locstripped', '$loc')");

 }
} 
?>

TY

0 Cevap