Question

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

Was it helpful?

Solution

You could use something like this:

$result = substr($original, strpos($original, '-') + 1);

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top