drownedbeaver — 2011-10-08T14:00:32-04:00 — #1
What if I have a string like these?
DANIEL JOHNS - GUITARIST - SILVERCHAIR
And I want to get just the word GUITARIST
from the string? How I supposed to do it?
Will I do 2 strpos?
Actually I tried 2 strpos already but on the second one, the dash is still there. so I got
the position of the first "-" again, thus generating an error.
or there is a shorter way to do it?
lemon_juice — 2011-10-08T19:39:07-04:00 — #2
You could try this:
$str = 'DANIEL JOHNS - GUITARIST - SILVERCHAIR';
$segm = explode('-', $str);
$word = trim($segm);
This will get you the second section of the string delimited by -.
You could also use substr() but then you have to know exactly from which to which position you need to extract the word.
drownedbeaver — 2011-10-09T00:34:02-04:00 — #3
Thanks LemonJuice! It worked! Solved....
You guys are the best.