0

I would like to strip everything in a string before a - and leave what's after that. For example:

15.11-101

I want to strip 15.11 and leave 101. I've tried a few different things, but can't seem to get it working, if anyone could help me out, that'd be fantastic :)

Cheers

Leanne

2 Answers 2

6

You could use something like this:

$result = substr($original, strpos($original, '-') + 1);
Sign up to request clarification or add additional context in comments.

Comments

3

assuming it appears only once, you can use the explode function.

$s='15.11-101';
$a=explode('-',$s,1);
echo $a[1];

This should be the fastest way.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.