-2

I want to cut a html link with php.

The html link is everytime the same pattern

domain.com/forum/members/84564-name.html

I want to get the 84564 from the name. the /forum/members/ is everytime the same. and the "-" after the user-id is also everstime the same. Can you help me to extract the user id?

PasiB
  • 97
  • 9
  • 1
    Welcome to StackOverflow! We will be glad to help you if you get stuck on a specific programming problem, but we are not here to write code for you. Please see [**How do I ask a good question?**](https://stackoverflow.com/help/how-to-ask) and [**What topics can I ask about here?**](https://stackoverflow.com/help/on-topic). – Alex Howansky Apr 20 '17 at 19:19
  • 1
    SO is not a code-writing service. That being said, use answer from this question to get string between `/forum/members/` and `-` http://stackoverflow.com/questions/5696412/get-substring-between-two-strings-php – Dimi Apr 20 '17 at 19:19

1 Answers1

0

I'm going to assume the user id may not always be 5 digits.

$domainSplit = explode("/", $theDomain); // split into parts
$theIdSplit=explode("-", $domainSplit[3]); // split 84564-name.html
$id=$theIdSplit[0];
Vbudo
  • 405
  • 4
  • 9