Jump to content

Getting Name from many URLs


Exoon

Recommended Posts

Hello,

 

Ive got many URLs like these which im trying to just get the name for example "Ace Lightning"

 

 

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

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>";
?>


 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.