Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Vowel and Consonent
- <?php
- $string = "Yousuf";
- $first_char = array(substr($string, 0,1));
- // echo "<pre>";
- // print_r($first_char);
- $a1 = array(
- "a", "e", "i", "o", "u",
- "A", "E", "I", "O", "U",
- );
- $a2 = array(
- "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z",
- "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z"
- );
- $vowel = array_intersect($first_char, $a1);// array_interstct() = matching a specic value
- $consonent = array_intersect($first_char, $a2);
- // echo "<pre>";
- // print_r($vowel);
- if ($first_char == $vowel) {
- echo "The string is vowel";
- }elseif ($first_char == $consonent) {
- echo "The string is consonent";
- }else{
- echo "The input is not a string";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement