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
https://forums.phpfreaks.com/topic/172154-solved-simple-parse-help/
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.

Archived

This topic is now archived and is closed to further replies.

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