| | |
I have a code in php that needs to be upgraded the situation
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 58
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
<html> <title> consonants vowels and numbers </title> <body bgcolor=red text=white><form method=post><font size=15> Enter a word(s):<input type=text name='phrase'></br> <input type=submit value=generate></br> <?php $vowel; $conso; $nums; switch($_POST['phrase']){ case'a': case'A': case'E': Case'e': Case'I': case'i': case'O': case'o': case'U': case'u': $vowel+=1; break; case'0': case'1': case'2': case'3': case'4': case'5': case'6': case'7': case'8': case'9': $nums+=1; break; default: $conso+=1; break; } echo"Vowels:",$vowel; echo"</br>"; echo"Consonants:",$conso; echo"</br>"; echo"Numbers:",$nums; echo"</br>"; ?> <input type=reset value=reset> </font> </form> </body> </html>
can someone tell me how to do it on full string type???
I need to count consonants the vowels and the numbers disregarding the spaces and special characters
Last edited by Ezzaral; Sep 14th, 2009 at 5:39 pm. Reason: Fixed code tags.
•
•
Join Date: Aug 2009
Posts: 25
Reputation:
Solved Threads: 2
You can access single characters within a string by using square brackets like the string is an array.
Using this method you could use code like this:
Using this method you could use code like this:
PHP Syntax (Toggle Plain Text)
$inputString = $_POST['phrase']; for($i = 0; $i < strlen($inputString); $i++) { $stringChar = $inputString[$i]; switch($stringChar) { //your switch statement code here } }
![]() |
Similar Threads
- Upload code for php BLOB (PHP)
- Music player code in php (PHP)
- PLS I NEED YOUR HELP! Help on Reading and Editing of already Written CODE on php! (PHP)
- executing c++ code from php (PHP)
- C code into php (PHP)
- C code into php (Community Introductions)
- Saving Code in PHP (MySQL)
Other Threads in the PHP Forum
- Previous Thread: how to see the value
- Next Thread: Fill Function
Views: 295 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for countingeverycharactersfromastring







