answersLogoWhite

0


Best Answer

$vowel_arr=array('a','e','i','o','u');

$string="This is my sentence";

$len=strlen($string);

$vowel_cnt=0;

for($i=0;$i<$len;$i++)

{

if(in_array($string[$i],$vowel_arr))

$vowel_cnt++;

else

continue;

}

echo "Total Vowel count is: ".$vowel_cnt;

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

1w ago

Here is an example of how you can find the vowels in a string using PHP:

$str = "Hello World";
$vowels = preg_match_all('/[aeiou]/i', $str, $matches);
echo "Vowels found: " . $vowels;

This code snippet uses a regular expression to match all vowels (both uppercase and lowercase) in the string "Hello World" and counts how many vowels are found.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Code of find vowels in string in php?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Linguistics

The PHP syntax is similar to which languages?

Its similar to a number of languages such as C, C++, Java and Perl.


How can you create a language converter for website in English to Spanish in PHP?

You can use PHP to create a language converter for a website by storing language translations in a database or files, and then using PHP to dynamically switch the content based on the selected language. You can create language files for each language, and then use PHP sessions or cookies to store the user's language preference across pages. Finally, use PHP functions to display the content in the appropriate language based on the user's selection.


How do you convert Text-to-Speech with PHP?

You can convert text to speech in PHP using APIs such as Google Text-to-Speech or Amazon Polly. These APIs allow you to send a text string and receive an audio file in response, which you can then play back or save. You would need to integrate with the API of your choice and handle the process of generating and playing the speech output.


How much is the salary of a Spanish speaking CSR in the Philippines?

I work as a Spanish-Speaking CSR. As with other (call-center CSR rates), they pay premium to experience. My first job as (with no experience yet) was Php 42,100.00. After a year I was recruited/pirated by a neighboring competitor and offered what seems to be +50%. I'm now at Php 63,150.00/month. (that's before taxes, of course).


How do you change the input language of a textbox from English to Hindi using PHP?

Changing the input language of a textbox from English to Hindi in PHP involves setting the lang attribute to &quot;hi&quot; in the input tag. This informs the browser that the expected language of the entered text should be Hindi. Additionally, you can utilize JavaScript to provide a virtual Hindi keyboard for users to input text easily in Hindi.

Related questions

How do you count the vowels in a string using PHP?

build an array of vowels then do a foreach on the array and then explode the string on the array value and the answer is -1 of the result


What does the php function eval?

The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php


How do you remove whitespaces from a string in PHP?

&lt;?php trim(ereg_replace( ' +', ' ', $extraWhiteSpace)); ?&gt;


What is var char in php?

Varchar in SQL means string in PHP.


How to use strings with PHP and MySQL?

If you will see this example as below, this may help. &lt;?php $string = mysql_real_escape_string($string); $sql = "insert into stringtable(mystring) values('$string')"; ?&gt;


What is difference between php and ruby on rails?

PHP is a scripting language while Ruby on Rails is a framework based on ruby programming language. PHP is easy to learn and code while Ruby is hard to learn and code. PHP Code is a mess and difficult to find particular functions or code while ROR follows systematic development and you can easily find the required function.


How do you get the length of an ANSI string using PHP?

$string ="Guess my length"; $length = strlen($string); now the $length will have the length of the string.


How do you take substring from a given string in php?

Use the substr function. For example &lt;?php $name= "naruto uzumaki"; echo substr($name, 0, 6) ; // The first six char are taken by this code ?&gt; This will output naruto


How do you check the length of a string in PHP?

It is fairly simple to check the length of a string in PHP. All you need to do is use the function strlen(). Below is an example of how it is used. &lt;?php $my_text = "Hello"; echo strlen($my_text); // outputs 5 ?&gt;


How do you count the vowels in a string?

#include #include void main() { char string[50]; int vowel=0,consonant=0; cout&lt;&lt;"Enter the string"; cin.getline(string,50); for(int i=0;string[i]!='\0';i++) { switch (string[i]) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U':vowel++; continue; } if (string[i]!=' ') consonant++; } cout&lt;&lt;"No of vowels="&lt;&lt;&lt;"\nNo of consonants="&lt;


What is syntax in php?

We can use php tags in different ways. &lt;?php //php code to be written here ?&gt; OR &lt;? //php code ?&gt; This tag will not work when we using editors such as macromedia dreamweaver. OR &lt; script language="php"&gt; //php code &lt;/script&gt;


How do you change the language code in a PHP page?

I have little idea of your question however &lt;?php #code in here ?&gt; is the starter for PHP, and then anything outside is HTML.