Jump to content

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


 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.