Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,693 questions

57,001 answers

573 users

How to find missing alphabet characters from a string in PHP

1 Answer

0 votes
function getMissingAlphabetChars(string $input): array {
    // Full alphabet
    $alphabet = range('a', 'z');

    // Normalize input: lowercase + keep only letters
    $letters = preg_replace('/[^a-z]/', '', strtolower($input));

    // Unique letters in the string
    $present = array_unique(str_split($letters));

    // Difference: alphabet minus present letters
    return array_values(array_diff($alphabet, $present));
}

$missing = getMissingAlphabetChars("PHP Programming");

print_r($missing);

        
 
/*
run:
             
Array
(
    [0] => b
    [1] => c
    [2] => d
    [3] => e
    [4] => f
    [5] => j
    [6] => k
    [7] => l
    [8] => q
    [9] => s
    [10] => t
    [11] => u
    [12] => v
    [13] => w
    [14] => x
    [15] => y
    [16] => z
)

*/

 



answered Mar 5 by avibootz
...