Forum Moderators: coopster

Message Too Old, No Replies

Finding capital letters and using explode.

         

dkin

1:38 am on Jun 9, 2005 (gmt 0)

10+ Year Member



Say I have this string "HEY ALL i have no idea what Im doing."

is there a way to explode that so that I can just take "HEY ALL"

?

RonPK

7:46 am on Jun 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless you really need to use the explode() method, a regexp might work:

$text = "HEY ALL i have no idea what Im doing."
$text = trim(preg_replace("/[^A-Z ]/", "", $text));
echo $text;

should show
HEY ALL I

[^A-Z ] matches everything that is not a capital letter or a whitespace.