Hi,
Can anyone tell me how to truncate text at a specific character?
For example, I have:
Hallelujah:Ahoy
And I want to return:
Hallelujah
Anyone know how I can do that? I looked at substr, but the # of characters after the colon will change.
echo strtok($str, ':');
Not to mention a hundred other ways using string functions.
What's a reply without a jab?
Thanks.
you could use explode()
$str = 'Hallelujah:Ahoy'; list($sub_str) = explode(':', $str); echo $sub_str . '<br />'; $substr = strtok($str, ':'); echo $sub_str . '<br />';
I think of it as a nudge.