How do I parse a string between two characters?
I have a string:
I want to make two variables out of this: the "13" and the "24". The first set of characters will always be between two dashes (-). The second set will be after the second dash to the end of the string.
How would I do this with PHP?
$string = 'somethingsomething-13-24' ; list( $one , $two ) = array_slice ( explode ( '-' , $string ), - 2 ); echo "one: $one , two: $two " ; // one: 13, two: 24
Mindzai, I owe you one. Thanks!
Best solution ever.
Actually, let's say that I want to keep the "somethingsomething" also. How would I do that?
$string = 'somethingsomething-13-24' ; list( $something , $one , $two ) = explode ( '-' , $string );
Users Browsing this Thread
There are currently 1 users browsing this thread.
(0 members and 1 guests)
Tags for this Thread