Exoon Posted May 20, 2011 Share Posted May 20, 2011 Hello, Ive got many URLs like these which im trying to just get the name for example "Ace Lightning" http://www.wupload.com/file/1374721/Ace Lightning # GBA.rar http://www.wupload.com/file/1374722/Action Man - Robotatak # GBA.rar http://www.wupload.com/file/1374726/Activision Anthology # GBA.rar http://www.wupload.com/file/1374761/Advance Guardian Heroes # GBA.rar http://www.wupload.com/file/1374764/Agassi Tennis Generation # GBA.rar This is my code <?php if($_POST['newlinks']) { $newlinks = $_POST["newlinks"]; $newlinks = preg_split("/.rar/", $newlinks); foreach ($newlinks as $newlink) { $r_name = substr("$newlink", 36, 100); echo "<strong>Game Name: $r_name</strong> <br />"; } } echo "<form method=\"POST\" action=\"index.php?page=mass-gba\">"; echo "<br /> <strong>Mass Add GBA ROMs</strong> <br />"; echo "<textarea rows=\"16\" name=\"newlinks\" cols=\"84\"></textarea>"; echo "<input type=\"submit\" value=\"Mass Add GBA Links\" name=\"B1\">"; echo "</form>"; ?> This results are like this, I cant understand why it works for the first game but not the second or any after that. True Name: Ace Lightning # GBA True Name: 2/Action Man - Robotatak # GBA True Name: 6/Activision Anthology # GBA True Name: 1/Advance Guardian Heroes # GBA True Name: 4/Agassi Tennis Generation # GBA Link to comment https://forums.phpfreaks.com/topic/236956-getting-name-from-many-urls/ Share on other sites More sharing options...
QuickOldCar Posted May 20, 2011 Share Posted May 20, 2011 Here's a get last path from url function I made. function getLastPath($url) { $trim_path = trim($url, '/'); $parts = explode('/', $trim_path); $last = end($parts); return $last; } or you can just integrate something like this <?php if($_POST['newlinks']) { $newlinks = $_POST["newlinks"]; $newlinks = preg_split("/.rar/", $newlinks); foreach ($newlinks as $newlink) { $trim_path = trim($newlink, '/'); $parts = explode('/', $trim_path); $r_name = end($parts); echo "<strong>Game Name: $r_name</strong> <br />"; } } echo "<form method=\"POST\" action=\"index.php?page=mass-gba\">"; echo "<br /> <strong>Mass Add GBA ROMs</strong> <br />"; echo "<textarea rows=\"16\" name=\"newlinks\" cols=\"84\"></textarea>"; echo "<input type=\"submit\" value=\"Mass Add GBA Links\" name=\"B1\">"; echo "</form>"; ?> Link to comment https://forums.phpfreaks.com/topic/236956-getting-name-from-many-urls/#findComment-1217994 Share on other sites More sharing options...
Exoon Posted May 20, 2011 Author Share Posted May 20, 2011 Thanks alot, works great. Link to comment https://forums.phpfreaks.com/topic/236956-getting-name-from-many-urls/#findComment-1217995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.