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

SQL In Static Id Wise Record Skip After Show Result