I've this code here:
$url = 'https://www.my-page.de/account/show/4913';
echo substr( $url, strrpos( $url, '/' ) + 1 );
This returns me the needed id:
4913
Now the problem begins. In some cases the URL looks like this:
$url = 'https://www.my-page.de/account/show/4913/';
$url = 'https://www.my-page.de/account/show/4913/?conversationId=xxx';
This means that my code don't works anymore. So is there any way to be 100 % sure that I always get my ID from the URL? The ID is always at the same position from the beginning on but the end can be different.
Update
When I've this code here I'm getting not the last part anymore. Any idea why and how to fix this?:
$url = 'https://my-page.de/account/show/4913/';
$id = basename( dirname( $url ) );
I just want to be sure that it works in every situation. In this case the selected part is:
show