Jump to content

[SOLVED] Simple Parse Help


phpretard

Recommended Posts

How can I pull just the "123" out of $var.

 

The numbers after the dash could be up to 10 digits

 

In the end I need eliminate the dash and put everything after the dash into $var2

 


$var="41bab296a65b71736b464f8aff39b342-123"

$var1="41bab296a65b71736b464f8aff39b342";

$dash="gone";

$var2="123";

 

Thank you.

Link to comment
Share on other sites

in order to remove the dash, you can use str_replace() to replace the dash with an empty string.

 

as for ignace's code, in case there are multiple dashes and you only want the very last portion, use:

 

$var2 = end($parts);

 

rather than specifying $parts[1] explicitly.

Link to comment
Share on other sites

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.