Forum Moderators: coopster
I think there must be some way to code this, but I'm not really sure how to start it and I'd greatly appreciate any input!
Here is what I'm trying to do. Let's imagine there is a text field stored in a database such as this one > VERY NICE SHOW, NOT TO BE MISSED This is the best show ever...
So the first part of it is written in all uppercase and the rest in normal up/lowercase mix. So what I'd like to do is isolate the 'uppercase only' part and display it all by itself. Basically break the text in two parts: one with the uppercase bit and the other with the rest of the text...
Any ideas on how I could start this?
Thank you,
AndieR
Thinking quickly this is what ive come up with:
function isupper($i)
{
return (strtoupper($i) === $i);
}$string = "VERY NICE SHOW, NOT TO BE MISSED this is the best show ever";
$last_loc = -1;
for($i = 0; $i < strlen($string); $i++)
{
if(isupper($string[$i])) {
$last_loc = $i;
}
else { break; }
}
$text = substr($string, 0, $last_loc);
echo $text;
Hope this helps
eelix