get first letter of each word

explode() on the spaces, then you use the [] notation to access the resultant strings as arrays:

$string = "Community College District";
$result = "CCD";
$words = explode(" ", "Community College District");
$acronym = "";
foreach ($words as $w) {
    $acronym .= $w[0];
}

Popular posts from this blog

Ajax Toggle(on/off) on-click Update

Yii Framework In Update Time View Image In Form