Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:13:03+00:00 2026-06-17T05:13:03+00:00

$word = Acrobat (or Apple, Tea etc.) How can I detect and echo the

  • 0
$word = "Acrobat" (or Apple, Tea etc.)

How can I detect and echo the last vowel of a given word with php? I tried preg_match function, google’d for hours but couldn’t find a proper solution.

There can be multibyte letters like ü, ö in the string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:13:04+00:00Added an answer on June 17, 2026 at 5:13 am

    Here’s a multibyte safe version of catching the last vowel in a string.

    $arr = array(
        'Apple','Tea','Strng','queue',
        'asartä','nő','ağır','NOËL','gør','æsc'
    );
    
    /*  these are the ones I found in character viewer
        in Mac so these vowels can be extended. don't
        forget to add both lower and upper case versions
        of new ones because personally I wouldn't rely
        on the i (case insensitive) flag in the pattern
        for multibyte characters.
    */
    $vowels =
        'aàáâãāăȧäảåǎȁąạḁẚầấẫẩằắẵẳǡǟǻậặæǽǣ' .
        'AÀÁÂÃĀĂȦÄẢÅǍȀȂĄẠḀẦẤẪẨẰẮẴẲǠǞǺẬẶÆǼǢ' .
        'EÈÉÊẼĒĔĖËẺĚȄȆẸȨĘḘḚỀẾỄỂḔḖỆḜ' .
        'eèéêẽēĕėëẻěȅȇẹȩęḙḛềếễểḕḗệḝ' .
        'IÌÍÎĨĪĬİÏỈǏỊĮȈȊḬḮ' .
        'iìíîĩīĭıïỉǐịįȉȋḭḯ' .
        'OÒÓÔÕŌŎȮÖỎŐǑȌȎƠǪỌØỒỐỖỔȰȪȬṌṐṒỜỚỠỞỢǬỘǾŒ' .
        'oòóôõōŏȯöỏőǒȍȏơǫọøồốỗổȱȫȭṍṏṑṓờớỡởợǭộǿœ' .
        'UÙÚÛŨŪŬÜỦŮŰǓȔȖƯỤṲŲṶṴṸṺǛǗǕǙỪỨỮỬỰ' .
        'uùúûũūŭüủůűǔȕȗưụṳųṷṵṹṻǖǜǘǖǚừứữửự'
    ;
    
    // set necessary encodings
    mb_internal_encoding('UTF-8');
    mb_regex_encoding('UTF-8');
    
    // and loop
    foreach ($arr as $word) {
    
        $vow = mb_ereg_replace('[^'.$vowels.']','',$word);
        // get rid of all consonants (non-vowels in this pattern)
        $lastVw = mb_substr($vow,-1);
        // and get the last one from the remaining vowels
    
        if (empty($lastVw))
        // it evaluates this line when there's no vowel in the string
            echo "there's no vowel in <b>\"$word\"</b>." . PHP_EOL;
        else
        // and vice versa
            echo "last vowel in <b>\"$word\"</b> is " .
            "<span style=\"color:#F00\">{$lastVw}</span>" . PHP_EOL;    
    }
    

    Here’s the output.

    last vowel in “Apple” is e
    last vowel in “Tea” is a
    there’s no vowel in “Strng”.
    last vowel in “queue” is e
    last vowel in “asartä” is ä
    last vowel in “nő” is ő
    last vowel in “ağır” is ı
    last vowel in “NOËL” is Ë
    last vowel in “gør” is ø
    last vowel in “æsc” is æ

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can u plz tell me how to validate the given file is word document
what word can i write to access static function inside class? like self:: in
Possible Duplicate: Remove entire word if the word contains specific string How I can
In Word you can place an image on a page and have the text
word 1 word 2 word 3 word 4 And so on... How can I
A word processor program features a search and replace function. However, partial words (character
When a word gets to long it messes the text up.... how can I
When I search a word apple the script is showing the result in the
join_word = ' '.join(word) len_join_word = len(join_word) I tried to get len of join_word
Word documents are split into pages by default. How do I remove the page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.