PHP Program to Find Missing Characters to Make a String Pangram Last Updated : 27 Dec, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to find the missing characters to make the string Pangram using PHP. A pangram is a sentence containing every letter in the English Alphabet. Examples: Input: The quick brown fox jumps over the dogOutput: Missing Characters - alyzInput: The quick brown fox jumpsOutput: Missing Characters - adglvyzTable of Content Using for() LoopUsing range() and strpos() MethodsPHP Program to Find Missing Characters to Make a String Pangram using for() LoopThe provided PHP code defines a function findMissingCharacters() that takes a string as input and identifies the missing characters required to make it a pangram. Example: In this example, we will find the missing number to make string pangram. PHP <?php function findMissingCharacters($str) { // Convert the string to lowercase $str = strtolower($str); // Create an array of all lowercase letters $alphabet = range('a', 'z'); $present_chars = []; $missing_chars = ''; // Check each character in the string for ($i = 0; $i < strlen($str); $i++) { $char = $str[$i]; if (ctype_alpha($char)) { $present_chars[$char] = true; } } // Check for missing characters foreach ($alphabet as $letter) { if (!isset($present_chars[$letter])) { $missing_chars .= $letter; } } return $missing_chars; } $str = "The quick brown fox jumps over the dog"; $missing_chars = findMissingCharacters($str); if (empty($missing_chars)) { echo "The string is a pangram.\n"; } else { echo "Missing characters: $missing_chars\n"; } ?> OutputMissing characters: alyz PHP Program to Find Missing Characters to Make a String Pangram using range() and strpos() MethodsThe range() and strpos() methods are used to find the missing number to make the string pangram. Example: PHP <?php function missingChars($str) { $result = ""; $str = strtolower($str); $letters = range('a', 'z'); foreach ($letters as $char) { if (strpos($str, $char) === false) { $result .= $char; } } return $result; } // Driver code $inputString = "The quick brown fox jumps over the dog"; $missingChars = missingChars($inputString); if ($missingChars === "") { echo "String is a pangram"; } else { echo "Missing characters to make the" . " string pangram: {$missingChars}"; } ?> OutputMissing characters to make the string pangram: alyz Comment More infoAdvertise with us Next Article Javascript Program to Check if a given string is Pangram or not B blalverma92 Follow Improve Article Tags : PHP Geeks Premier League 2023 Similar Reads Javascript Program to Check if a given string is Pangram or not In this article, we are going to implement algorithms to check whether a given string is a pangram or not. Pangram strings are those strings that contain all the English alphabets in them.Example: Input: âFive or six big jet planes zoomed quickly by tower.â Output: is a Pangram Explanation: Does'not 7 min read How to replace multiple characters in a string in PHP ? A string is a sequence of characters enclosed within single or double quotes. A string can also be looped through and modifications can be made to replace a particular sequence of characters in it. In this article, we will see how to replace multiple characters in a string in PHP.Using the str_repla 3 min read How to get the position of character in a string in PHP ? In this article, we will get the position of the character in the given string in PHP. String is a set of characters. We will get the position of the character in a string by using strpos() function. Syntax: strpos(string, character, start_pos) Parameters: string (mandatory): This parameter refers t 2 min read How to read each character of a string in PHP ? A string is a sequence of characters. It may contain integers or even special symbols. Every character in a string is stored at a unique position represented by a unique index value. Here are some approaches to read each character of a string in PHPTable of ContentUsing str_split() method - The str_ 4 min read PHP Different characters in the given string Different characters in a given string refer to the unique, non-repeating characters that appear within the string. Identifying these characters involves recognizing each distinct character while excluding any duplicates. This concept is useful in various programming and data analysis tasks where un 2 min read PHP Different characters in the given string Different characters in a given string refer to the unique, non-repeating characters that appear within the string. Identifying these characters involves recognizing each distinct character while excluding any duplicates. This concept is useful in various programming and data analysis tasks where un 2 min read Like