Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5988197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:55:30+00:00 2026-05-22T22:55:30+00:00

Let say we have link as following for link as ****.com/index.php?id=4 the <?=$id?> is

  • 0

Let say we have link as following

for link as ****.com/index.php?id=4

the <?=$id?> is 4

for link as ****.com/4

the <?=$id?> is 4

for link as ****.com/4-keyowrd-keyword

$realid = array_shift(explode("-", $id));

so <?=$realid?> is 4

Now my question is for link as ****.com/4/keyword-keyword

How then get the id as 4 is there any way to do it ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:55:31+00:00Added an answer on May 22, 2026 at 10:55 pm

    If you actually have a complete URL with the scheme included (i.e.: http://something.com and not just something.com), you can do:

    // Search in the query string
    $url = 'http://something.php/index.php?id=4';
    $query = parse_url($url, PHP_URL_QUERY);
    parse_str($query, $queryArr);
    $id = $queryArr['id'];
    echo $id; // 4
    
    // Search in the path
    $url = 'http://something.com/4/keyword-keyword';
    $path = parse_url($url, PHP_URL_PATH);
    $id = basename(dirname($path));
    echo $id; // 4
    
    // Search in the path (undefined length)
    $url = 'http://something.com/4/keyword-keyword/foo/bar';
    $path = parse_url($url, PHP_URL_PATH);
    list(,$id) = explode('/', $path);
    echo $id; // 4
    

    If you don’t the scheme there, you can just prepend it, like:

    $url = 'http://'.$url;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following link: www.blahblah.com/#!?page=index How can I convert it to
Let's say I have a web page ( /index.html ) that contains the following
Let's say I have the following code: <div id=link_other> <ul> <li><a href=http://www.google.com/>google</a></li> <li> <div
Let's say I have a link: <a href='http://example.com/file.zip' id='dl'>Download</a> And while someone click on
Let's say I have the following HTML code: <a href=/site/somesite/> somesite</a> My question is
Let's say I have the following link: <a href=# onclick=alert('You clicked a link.');>Click Me!</a>
Let's say we have the following list: <ul> <li><a href=#>Link 1</a></li> <li><a href=#>Link 2</a></li>
Let say I have the following data in R. training = factor(c(1,1,3,2,1,3,2,34,67,34)) test =
Let's say I have the following scenario: ComObjectClass firstCOMObject = new ComObjectClass(); ComObjectClass secondCOMObject
I'm developing a shared library. Let's say I have the following class definition: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.