Script PHP pour déterminer si la lettre Y est une consonne ou une voyelle
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
Si je change la boucle de voyelle à
Presque tous les cas travaillent sauf Yvonne obtient encore foirée
PHP Code: [ Select ]
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
echo $word_array[$i] . ' in If';
// Y is after vowel so it is a constant
$return_array[$word][$i] = 'consonant<br>';
} /*else if(strpos($word_array[$i], 'y') + 1 == $vowels_check['vowels'][$j]['pos']) {
echo $word_array[$i] . ' in else If<br>';
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}*/ else {
echo $word_array[$i] . ' in else<br><br>';
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}
}
}
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
echo $word_array[$i] . ' in If';
// Y is after vowel so it is a constant
$return_array[$word][$i] = 'consonant<br>';
} /*else if(strpos($word_array[$i], 'y') + 1 == $vowels_check['vowels'][$j]['pos']) {
echo $word_array[$i] . ' in else If<br>';
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}*/ else {
echo $word_array[$i] . ' in else<br><br>';
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}
}
}
- // Loop Vowels found
- for($j=0; $j<count($vowels_check['vowels']); $j++) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- // Check position of vowel
- if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
- echo $word_array[$i] . ' in If';
- // Y is after vowel so it is a constant
- $return_array[$word][$i] = 'consonant<br>';
- } /*else if(strpos($word_array[$i], 'y') + 1 == $vowels_check['vowels'][$j]['pos']) {
- echo $word_array[$i] . ' in else If<br>';
- // Y is before vowel so it is a Vowel
- $return_array[$word][$i] = 'vowel';
- }*/ else {
- echo $word_array[$i] . ' in else<br><br>';
- // Y is before vowel so it is a Vowel
- $return_array[$word][$i] = 'vowel';
- }
- }
- }
Presque tous les cas travaillent sauf Yvonne obtient encore foirée
- Anonymous
- Bot


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Décembre 21st, 2012, 8:20 pm
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
Fonction y cocher mise à jour
PHP Code: [ Select ]
function check_y($word) {
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
} else {
//echo $word_array[$i] . ' ';
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
// Y is after vowel so it is a constant
$return_array[$word][$i] = 'consonant<br>';
} else {
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}
}
}
}
}
// Return the return array
return $return_array;
}
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
} else {
//echo $word_array[$i] . ' ';
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
// Y is after vowel so it is a constant
$return_array[$word][$i] = 'consonant<br>';
} else {
// Y is before vowel so it is a Vowel
$return_array[$word][$i] = 'vowel';
}
}
}
}
}
// Return the return array
return $return_array;
}
- function check_y($word) {
- // Start the class
- $syllable = new Syllable('en-us');
- // Make th word lower case
- $word = strtolower($word);
- // Check for Y
- if(strpos($word, 'y') === false) {
- // No Y found
- return 'No Y Found';
- }
- // Make an array to return info
- $return_array = array();
- // Breakword into syllables
- $syllable->setTreshold(Syllable::TRESHOLD_MOST);
- $word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
- // Loop the word array
- for($i=0; $i<count($word_array); $i++) {
- // Check for vowels
- $vowels_check = vowel_check($word_array[$i]);
- // Check for no vowels
- if(!$vowels_check['found']) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- // No Vowels found so Y is a vowel
- $return_array[$word][$i] = 'vowel';
- }
- } else {
- //echo $word_array[$i] . ' ';
- // Loop Vowels found
- for($j=0; $j<count($vowels_check['vowels']); $j++) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- // Check position of vowel
- if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
- // Y is after vowel so it is a constant
- $return_array[$word][$i] = 'consonant<br>';
- } else {
- // Y is before vowel so it is a Vowel
- $return_array[$word][$i] = 'vowel';
- }
- }
- }
- }
- }
- // Return the return array
- return $return_array;
- }
- wpas
- Graduate


- Inscription: Juil 12, 2010
- Messages: 214
- Loc: Canada
- Status: Offline
Plus je creuse dans tout cela, obtenir des opinions les plus divergentes, même pourquoi j'ai contacté quelques anglais enseigne.
Pour essayer un étroit de ce fait, je suis venu avec deux choses que j'ai été compte tenu du fait que je vais utiliser comme une base pour le test.
Règle 1
Si vous remplacez la lettre y le /j/ sonore et le mot sonne presque la même chose alors c'est une consonne, même si vous semblerait avoir un accent.
par exemple, yell serait presque le même son avec /j/ y est conforme
jour sonnerait pas la même chose avec/j /, donc y est une voyelle.
Règle 2
Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, encore).
Règle 3
S'il n'y a pas de voyelles dans le mot y est une voyelle tels que salle de sport.
Si elle prend la place de la voyelle, y est une voyelle comme système.
Je ne sais pas comment corriger je suis, mais c'est où je voudrais commencer.
Basé sur ce qui précède, j'ai créé ce qui suit pour le test :
Pour les voyelles :
check_test (tout le monde de bébé betty garçon bryan de cyclotourisme candy cri cycle jour sec dynamique elly mouche volant au revoir gym heureux poilue hymne joy lynn Marie beaucoup mon mythe mystère jouer psycho pry poney rapidement rythme rime de seigle dire timide ciel spy sly soja symbole seringue petit try trendy très vinyle pourquoi wyatt yvonne)
Pour les consonnes :
check_test (hey touche kyle yahoo d'yacht lloyd oyster joueur yale yam fil rendement yell jaune Eltsine Oui hier encore yoda yogourt yoke yolanda young vous votre yvette royce)
Dans les deux cas :
check_test("Sydney")
Si quelqu'un a des suggestions supplémentaires, je serais très heureux de vous entendre.
Pour essayer un étroit de ce fait, je suis venu avec deux choses que j'ai été compte tenu du fait que je vais utiliser comme une base pour le test.
Règle 1
Si vous remplacez la lettre y le /j/ sonore et le mot sonne presque la même chose alors c'est une consonne, même si vous semblerait avoir un accent.
par exemple, yell serait presque le même son avec /j/ y est conforme
jour sonnerait pas la même chose avec/j /, donc y est une voyelle.
Règle 2
Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, encore).
Règle 3
S'il n'y a pas de voyelles dans le mot y est une voyelle tels que salle de sport.
Si elle prend la place de la voyelle, y est une voyelle comme système.
Je ne sais pas comment corriger je suis, mais c'est où je voudrais commencer.
Basé sur ce qui précède, j'ai créé ce qui suit pour le test :
Pour les voyelles :
check_test (tout le monde de bébé betty garçon bryan de cyclotourisme candy cri cycle jour sec dynamique elly mouche volant au revoir gym heureux poilue hymne joy lynn Marie beaucoup mon mythe mystère jouer psycho pry poney rapidement rythme rime de seigle dire timide ciel spy sly soja symbole seringue petit try trendy très vinyle pourquoi wyatt yvonne)
Pour les consonnes :
check_test (hey touche kyle yahoo d'yacht lloyd oyster joueur yale yam fil rendement yell jaune Eltsine Oui hier encore yoda yogourt yoke yolanda young vous votre yvette royce)
Dans les deux cas :
check_test("Sydney")
Si quelqu'un a des suggestions supplémentaires, je serais très heureux de vous entendre.
http://www.schembrionics.com
The Ultimate Solutions Center
The Ultimate Solutions Center
- wpas
- Graduate


- Inscription: Juil 12, 2010
- Messages: 214
- Loc: Canada
- Status: Offline
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
La règle 1 est la règle qui va être le plus difficile à obtenir correcte.
y a-t-il une corrélation avec la voyelle à l'o qui serait constamment les mêmes
Exemple
Oy ay et uy en voyelles...garçon jour acheter
et ey en consonnes...hey
Si c'est le cas cela devrait rendre les choses un peu plus facile
y a-t-il une corrélation avec la voyelle à l'o qui serait constamment les mêmes
Exemple
Oy ay et uy en voyelles...garçon jour acheter
et ey en consonnes...hey
Si c'est le cas cela devrait rendre les choses un peu plus facile
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
Aussi ces paroles
Ceux-ci ont l'oy qui, dans votre « soy » d'exemple était une voyelle
Royce
Lloyd
Oyster
Et le joueur a un ressembler à un jour
joueur
Si tous mes post sont corrects, je pense que je peux avoir un script modifié qui répond à toutes les règles qui peuvent être mis à l'essai
Ceux-ci ont l'oy qui, dans votre « soy » d'exemple était une voyelle
Royce
Lloyd
Oyster
Et le joueur a un ressembler à un jour
joueur
Si tous mes post sont corrects, je pense que je peux avoir un script modifié qui répond à toutes les règles qui peuvent être mis à l'essai
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
Ici est mis à jour le code pour tester avec
PHP Code: [ Select ]
<?php
// Include the class
require_once(dirname(__FILE__) . '/Syllable.php');
function vowel_check($word) {
// Setup an array of vowels
$vowels = array('a', 'e', 'i', 'o', 'u');
// Make an return array
$return_array = array("found" => false);
// Make a counter
$ii = 0;
// Loop the letters
for($i=0; $i<strlen($word); $i++) {
// Check for vowels
if(in_array($word[$i], $vowels)) {
// Set found to true
$return_array['found'] = true;
// Build the info
$return_array['vowels'][$ii]['letter'] = $word[$i];
$return_array['vowels'][$ii]['pos'] = strpos($word, $word[$i]);
// Add to counter
$ii++;
}
}
// Return $return_array
return $return_array;
}
function check_y($word) {
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
if(strpos($word_array[$i], 'y') == 0) {
// No Vowels and y is the first letter of the word
$return_array[$word][$i] = 'consonant';
} else {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
}
} else {
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
switch(true) {
// Vowel before and vowel being o a or u
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Vowel before and vowel being e or i
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// YV fix the syllable class does not break the yv apart into the correct syllable grouping so this is a fix to
// counter act this issue
case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Y is first letter
case (strpos($word_array[$i], 'y') == 0):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
}
}
}
}
}
// Return the return array
return $return_array;
}
echo '<pre>';
var_dump(check_text('boy Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
//var_dump(check_text('anyone baby betty boy bryan by bycycle candy cry cycle day dry dynamic elly fly flying goodbye gym happy hairy hymn joy lynn many mary my mystery myth play pony pry psycho quickly rye rhyme rhythm say shy sky sly spy soy symbol syringe tiny trendy try very vinyl why wyatt yvonne yvette'));
//var_dump(check_text('hey key kyle lloyd oyster player yacht yahoo yale yam yarn yield yell yellow yeltsin yes yesterday yet yoda yogurt yoke yolanda you young your royce'));
//check_text('Sylvia');
echo '</pre>';
function check_text($text) {
// Make sure we have text
if(empty($text)) {
// Kick back
return false;
}
// Break text into words
$text_array = explode(' ', $text);
// Make an array to return info
$return_array = array();
// Loop Text
for($i=0; $i<count($text_array); $i++) {
// Check the word
$temp_array = check_y($text_array[$i]);
if(!empty($temp_array)) {
// Add to the return array
$return_array[] = $temp_array;
}
}
// Return the array
return $return_array;
}
?>
// Include the class
require_once(dirname(__FILE__) . '/Syllable.php');
function vowel_check($word) {
// Setup an array of vowels
$vowels = array('a', 'e', 'i', 'o', 'u');
// Make an return array
$return_array = array("found" => false);
// Make a counter
$ii = 0;
// Loop the letters
for($i=0; $i<strlen($word); $i++) {
// Check for vowels
if(in_array($word[$i], $vowels)) {
// Set found to true
$return_array['found'] = true;
// Build the info
$return_array['vowels'][$ii]['letter'] = $word[$i];
$return_array['vowels'][$ii]['pos'] = strpos($word, $word[$i]);
// Add to counter
$ii++;
}
}
// Return $return_array
return $return_array;
}
function check_y($word) {
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
if(strpos($word_array[$i], 'y') == 0) {
// No Vowels and y is the first letter of the word
$return_array[$word][$i] = 'consonant';
} else {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
}
} else {
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
switch(true) {
// Vowel before and vowel being o a or u
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Vowel before and vowel being e or i
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// YV fix the syllable class does not break the yv apart into the correct syllable grouping so this is a fix to
// counter act this issue
case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Y is first letter
case (strpos($word_array[$i], 'y') == 0):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
}
}
}
}
}
// Return the return array
return $return_array;
}
echo '<pre>';
var_dump(check_text('boy Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
//var_dump(check_text('anyone baby betty boy bryan by bycycle candy cry cycle day dry dynamic elly fly flying goodbye gym happy hairy hymn joy lynn many mary my mystery myth play pony pry psycho quickly rye rhyme rhythm say shy sky sly spy soy symbol syringe tiny trendy try very vinyl why wyatt yvonne yvette'));
//var_dump(check_text('hey key kyle lloyd oyster player yacht yahoo yale yam yarn yield yell yellow yeltsin yes yesterday yet yoda yogurt yoke yolanda you young your royce'));
//check_text('Sylvia');
echo '</pre>';
function check_text($text) {
// Make sure we have text
if(empty($text)) {
// Kick back
return false;
}
// Break text into words
$text_array = explode(' ', $text);
// Make an array to return info
$return_array = array();
// Loop Text
for($i=0; $i<count($text_array); $i++) {
// Check the word
$temp_array = check_y($text_array[$i]);
if(!empty($temp_array)) {
// Add to the return array
$return_array[] = $temp_array;
}
}
// Return the array
return $return_array;
}
?>
- <?php
- // Include the class
- require_once(dirname(__FILE__) . '/Syllable.php');
- function vowel_check($word) {
- // Setup an array of vowels
- $vowels = array('a', 'e', 'i', 'o', 'u');
- // Make an return array
- $return_array = array("found" => false);
- // Make a counter
- $ii = 0;
- // Loop the letters
- for($i=0; $i<strlen($word); $i++) {
- // Check for vowels
- if(in_array($word[$i], $vowels)) {
- // Set found to true
- $return_array['found'] = true;
- // Build the info
- $return_array['vowels'][$ii]['letter'] = $word[$i];
- $return_array['vowels'][$ii]['pos'] = strpos($word, $word[$i]);
- // Add to counter
- $ii++;
- }
- }
- // Return $return_array
- return $return_array;
- }
- function check_y($word) {
- // Start the class
- $syllable = new Syllable('en-us');
- // Make th word lower case
- $word = strtolower($word);
- // Check for Y
- if(strpos($word, 'y') === false) {
- // No Y found
- return 'No Y Found';
- }
- // Make an array to return info
- $return_array = array();
- // Breakword into syllables
- $syllable->setTreshold(Syllable::TRESHOLD_MOST);
- $word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
- // Loop the word array
- for($i=0; $i<count($word_array); $i++) {
- // Check for vowels
- $vowels_check = vowel_check($word_array[$i]);
- // Check for no vowels
- if(!$vowels_check['found']) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- if(strpos($word_array[$i], 'y') == 0) {
- // No Vowels and y is the first letter of the word
- $return_array[$word][$i] = 'consonant';
- } else {
- // No Vowels found so Y is a vowel
- $return_array[$word][$i] = 'vowel';
- }
- }
- } else {
- // Loop Vowels found
- for($j=0; $j<count($vowels_check['vowels']); $j++) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- // Check position of vowel
- switch(true) {
- // Vowel before and vowel being o a or u
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
- // Y is s vowel
- $return_array[$word][$i] = 'vowel';
- // Kickout
- break;
- // Vowel before and vowel being e or i
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
- // Y is s consonant
- $return_array[$word][$i] = 'consonant';
- // Kickout
- break;
- // YV fix the syllable class does not break the yv apart into the correct syllable grouping so this is a fix to
- // counter act this issue
- case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
- // Y is s vowel
- $return_array[$word][$i] = 'vowel';
- // Kickout
- break;
- // Y is first letter
- case (strpos($word_array[$i], 'y') == 0):
- // Y is s consonant
- $return_array[$word][$i] = 'consonant';
- // Kickout
- break;
- }
- }
- }
- }
- }
- // Return the return array
- return $return_array;
- }
- echo '<pre>';
- var_dump(check_text('boy Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
- //var_dump(check_text('anyone baby betty boy bryan by bycycle candy cry cycle day dry dynamic elly fly flying goodbye gym happy hairy hymn joy lynn many mary my mystery myth play pony pry psycho quickly rye rhyme rhythm say shy sky sly spy soy symbol syringe tiny trendy try very vinyl why wyatt yvonne yvette'));
- //var_dump(check_text('hey key kyle lloyd oyster player yacht yahoo yale yam yarn yield yell yellow yeltsin yes yesterday yet yoda yogurt yoke yolanda you young your royce'));
- //check_text('Sylvia');
- echo '</pre>';
- function check_text($text) {
- // Make sure we have text
- if(empty($text)) {
- // Kick back
- return false;
- }
- // Break text into words
- $text_array = explode(' ', $text);
- // Make an array to return info
- $return_array = array();
- // Loop Text
- for($i=0; $i<count($text_array); $i++) {
- // Check the word
- $temp_array = check_y($text_array[$i]);
- if(!empty($temp_array)) {
- // Add to the return array
- $return_array[] = $temp_array;
- }
- }
- // Return the array
- return $return_array;
- }
- ?>
- wpas
- Graduate


- Inscription: Juil 12, 2010
- Messages: 214
- Loc: Canada
- Status: Offline
Hey ScottG
Après avoir soigneusement au-dessus de tout, j'avais été mauvais dans certains domaines. Après les heures d'étude, je crois que ce qui suit est probablement le plus juste pour la lettre y.
1. les mots avec « oy » la lettre y est une voyelle
par exemple, boy, joie, jouet, roy
2. les mots avec ay, ey et uy la lettre y est une consonne
par exemple, payer, disons, jour, clé, acheter, maire, murray, maloney
3. Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, pourtant, yolanda, yoda), créant la « yuh » sonore. Dans le lecteur de mot, le « yuh » retentisse, donc y est une consonne.
4. S'il n'y a pas de voyelles dans le mot y est une voyelle tels que gym, Lynn, Yvonne, Yvette, Marie, Betty, Elly et Bryan.
Si elle prend la place de la voyelle, y est une voyelle comme système, Bryan et Wyatt.
5. Autres exemples
-Billy, Sylvia, Missy, Kyle, Blythe, Sylvester et Katy, l'Y est une voyelle
-Dans la salle de gym, ma, cycle, ciel poilu, bébé, le y est une voyelle
-Kay, Eltsine, mai et Kuykendahl, l'Y est une consonne.
-À Sydney, le premier Y est une voyelle, la seconde Y est une consonne.
-In Oui, yam, yell, jaune, yogourt, yale l'y est une consonne.
Après avoir soigneusement au-dessus de tout, j'avais été mauvais dans certains domaines. Après les heures d'étude, je crois que ce qui suit est probablement le plus juste pour la lettre y.
1. les mots avec « oy » la lettre y est une voyelle
par exemple, boy, joie, jouet, roy
2. les mots avec ay, ey et uy la lettre y est une consonne
par exemple, payer, disons, jour, clé, acheter, maire, murray, maloney
3. Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, pourtant, yolanda, yoda), créant la « yuh » sonore. Dans le lecteur de mot, le « yuh » retentisse, donc y est une consonne.
4. S'il n'y a pas de voyelles dans le mot y est une voyelle tels que gym, Lynn, Yvonne, Yvette, Marie, Betty, Elly et Bryan.
Si elle prend la place de la voyelle, y est une voyelle comme système, Bryan et Wyatt.
5. Autres exemples
-Billy, Sylvia, Missy, Kyle, Blythe, Sylvester et Katy, l'Y est une voyelle
-Dans la salle de gym, ma, cycle, ciel poilu, bébé, le y est une voyelle
-Kay, Eltsine, mai et Kuykendahl, l'Y est une consonne.
-À Sydney, le premier Y est une voyelle, la seconde Y est une consonne.
-In Oui, yam, yell, jaune, yogourt, yale l'y est une consonne.
http://www.schembrionics.com
The Ultimate Solutions Center
The Ultimate Solutions Center
- wpas
- Graduate


- Inscription: Juil 12, 2010
- Messages: 214
- Loc: Canada
- Status: Offline
J'ai couru votre nouveau script et basée sur de nouvelles règles dans mon post précédent suivants besoins changeant :
Kay: y a déclaré que la voyelle, mais doit être conforme
mai: y a déclaré que la voyelle, mais doit être conforme
kuykendahl: y a déclaré que la voyelle, mais doit être conforme
Murray: y a déclaré que la voyelle, mais doit être conforme
J'ai étudié ces mots plus loin et ils n'ont en effet tous spécifié comme y étant une consonne.
Kay: y a déclaré que la voyelle, mais doit être conforme
mai: y a déclaré que la voyelle, mais doit être conforme
kuykendahl: y a déclaré que la voyelle, mais doit être conforme
Murray: y a déclaré que la voyelle, mais doit être conforme
J'ai étudié ces mots plus loin et ils n'ont en effet tous spécifié comme y étant une consonne.
http://www.schembrionics.com
The Ultimate Solutions Center
The Ultimate Solutions Center
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
OK alors voici la fonction de y cocher modifiée basée sur le nouvel ensemble de règles
Passé tous les exemples que vous avez fournies
Passé tous les exemples que vous avez fournies
PHP Code: [ Select ]
function check_y($word) {
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
if(strpos($word_array[$i], 'y') == 0) {
// No Vowels and y is the first letter of the word
$return_array[$word][$i] = 'consonant';
} else {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
}
} else {
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
switch(true) {
// Vowel before and vowel being o
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Vowel before and vowel being a, e, i or u
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// YV fix the sylible class does not break the yv apart into the correct sylible grouping so this is a fix to
// counter act this issue
case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Y is first letter
case (strpos($word_array[$i], 'y') == 0):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// Y not next two vowels
default:
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
}
}
}
}
}
// Return the return array
return $return_array;
}
// Start the class
$syllable = new Syllable('en-us');
// Make th word lower case
$word = strtolower($word);
// Check for Y
if(strpos($word, 'y') === false) {
// No Y found
return 'No Y Found';
}
// Make an array to return info
$return_array = array();
// Breakword into syllables
$syllable->setTreshold(Syllable::TRESHOLD_MOST);
$word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
// Loop the word array
for($i=0; $i<count($word_array); $i++) {
// Check for vowels
$vowels_check = vowel_check($word_array[$i]);
// Check for no vowels
if(!$vowels_check['found']) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
if(strpos($word_array[$i], 'y') == 0) {
// No Vowels and y is the first letter of the word
$return_array[$word][$i] = 'consonant';
} else {
// No Vowels found so Y is a vowel
$return_array[$word][$i] = 'vowel';
}
}
} else {
// Loop Vowels found
for($j=0; $j<count($vowels_check['vowels']); $j++) {
// Check for Y
if(strpos($word_array[$i], 'y') !== false) {
// Check position of vowel
switch(true) {
// Vowel before and vowel being o
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Vowel before and vowel being a, e, i or u
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// YV fix the sylible class does not break the yv apart into the correct sylible grouping so this is a fix to
// counter act this issue
case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
// Y is first letter
case (strpos($word_array[$i], 'y') == 0):
// Y is s consonant
$return_array[$word][$i] = 'consonant';
// Kickout
break;
// Y not next two vowels
default:
// Y is s vowel
$return_array[$word][$i] = 'vowel';
// Kickout
break;
}
}
}
}
}
// Return the return array
return $return_array;
}
- function check_y($word) {
- // Start the class
- $syllable = new Syllable('en-us');
- // Make th word lower case
- $word = strtolower($word);
- // Check for Y
- if(strpos($word, 'y') === false) {
- // No Y found
- return 'No Y Found';
- }
- // Make an array to return info
- $return_array = array();
- // Breakword into syllables
- $syllable->setTreshold(Syllable::TRESHOLD_MOST);
- $word_array = explode('­', utf8_encode($syllable->hyphenateText($word)));
- // Loop the word array
- for($i=0; $i<count($word_array); $i++) {
- // Check for vowels
- $vowels_check = vowel_check($word_array[$i]);
- // Check for no vowels
- if(!$vowels_check['found']) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- if(strpos($word_array[$i], 'y') == 0) {
- // No Vowels and y is the first letter of the word
- $return_array[$word][$i] = 'consonant';
- } else {
- // No Vowels found so Y is a vowel
- $return_array[$word][$i] = 'vowel';
- }
- }
- } else {
- // Loop Vowels found
- for($j=0; $j<count($vowels_check['vowels']); $j++) {
- // Check for Y
- if(strpos($word_array[$i], 'y') !== false) {
- // Check position of vowel
- switch(true) {
- // Vowel before and vowel being o
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
- // Y is s vowel
- $return_array[$word][$i] = 'vowel';
- // Kickout
- break;
- // Vowel before and vowel being a, e, i or u
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
- case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
- // Y is s consonant
- $return_array[$word][$i] = 'consonant';
- // Kickout
- break;
- // YV fix the sylible class does not break the yv apart into the correct sylible grouping so this is a fix to
- // counter act this issue
- case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
- // Y is s vowel
- $return_array[$word][$i] = 'vowel';
- // Kickout
- break;
- // Y is first letter
- case (strpos($word_array[$i], 'y') == 0):
- // Y is s consonant
- $return_array[$word][$i] = 'consonant';
- // Kickout
- break;
- // Y not next two vowels
- default:
- // Y is s vowel
- $return_array[$word][$i] = 'vowel';
- // Kickout
- break;
- }
- }
- }
- }
- }
- // Return the return array
- return $return_array;
- }
- wpas
- Graduate


- Inscription: Juil 12, 2010
- Messages: 214
- Loc: Canada
- Status: Offline
J'ai pensé que si j'ai creusé assez, je trouverais finalement un consensus général sur la façon de déterminer quand la lettre Y est une voyelle ou une consonne. Heureusement pour moi, elle a approuvé les règles, que j'ai l'intention d'utiliser.
Voici ce que j'ai trouvé :
Si une syllabe commence par Y, et la prochaine lettre représente une voyelle, Y représente certainement une consonne. Dans « yo » par exemple, Y représente une consonne.
Si une syllabe commence par Y et la prochaine lettre représente une consonne, le Y représente une voyelle, comme Yvonne, Yvette, Yves, l'yttrium.
Dans des mots comme "rythme", Y représente une voyelle, spécifiquement court et j'ai l'air. Toutefois, en un mot tel que le nom "Reynold", il ne fait pas sens de dire que Y représente une voyelle. C'est la combinaison de deux lettres E-Y qui représente une voyelle y ici est une consonne.
Dans une syllabe mots tels que « par » et "fly", Y représente la voyelle communément appelé depuis longtemps j'ai.
Dans les mots plus longs tels que "Désolé" et "amical", il représente la voyelle longue e (ou peut-être je court à nouveau — haut-parleurs varient).
Dans des mots comme "hey" ou "jour, les combinaisons de lettres de E-Y et A Y représentent ensemble le long A sound dans ces mots ici y est une consonne.
Pour les Y à la fin d'un mot comme « boy », « oy » est une diphtongue, consistant en une voyelle O ressemblant suivie E long ou court j'ai.
Il y a débat entre phonéticiens sur météo y est une voyelle ou consonne. Ils ne pas tous d'accord là-dessus.
Dans mon cas, j'ai choisi de rendre une voyelle.
Alors, Y obtient représenter une voyelle dans de nombreux mots. Il représente court je dans des termes tels "gym" et soit brève I ou E long dans des termes tels « heureux ». Il s'agit d'une diphtongue dans des termes tels « par ».
Voici ce que j'ai trouvé :
Si une syllabe commence par Y, et la prochaine lettre représente une voyelle, Y représente certainement une consonne. Dans « yo » par exemple, Y représente une consonne.
Si une syllabe commence par Y et la prochaine lettre représente une consonne, le Y représente une voyelle, comme Yvonne, Yvette, Yves, l'yttrium.
Dans des mots comme "rythme", Y représente une voyelle, spécifiquement court et j'ai l'air. Toutefois, en un mot tel que le nom "Reynold", il ne fait pas sens de dire que Y représente une voyelle. C'est la combinaison de deux lettres E-Y qui représente une voyelle y ici est une consonne.
Dans une syllabe mots tels que « par » et "fly", Y représente la voyelle communément appelé depuis longtemps j'ai.
Dans les mots plus longs tels que "Désolé" et "amical", il représente la voyelle longue e (ou peut-être je court à nouveau — haut-parleurs varient).
Dans des mots comme "hey" ou "jour, les combinaisons de lettres de E-Y et A Y représentent ensemble le long A sound dans ces mots ici y est une consonne.
Pour les Y à la fin d'un mot comme « boy », « oy » est une diphtongue, consistant en une voyelle O ressemblant suivie E long ou court j'ai.
Il y a débat entre phonéticiens sur météo y est une voyelle ou consonne. Ils ne pas tous d'accord là-dessus.
Dans mon cas, j'ai choisi de rendre une voyelle.
Alors, Y obtient représenter une voyelle dans de nombreux mots. Il représente court je dans des termes tels "gym" et soit brève I ou E long dans des termes tels « heureux ». Il s'agit d'une diphtongue dans des termes tels « par ».
http://www.schembrionics.com
The Ultimate Solutions Center
The Ultimate Solutions Center
- alemao_brazil
- Newbie


- Inscription: Fév 20, 2012
- Messages: 8
- Status: Offline
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 266
- Status: Offline
J'ai fait un test avec votre suggestion sur l'utilisation de preg_match et utilisé des mots comme Sydney où y est une voyelle et une consonne il ne retourne rien. Désolé je n'a pas répondu à votre message plus tôt Ive été un peu occupé à construire un arbre de Noël et avant d'aller au lit ou lorsque je me suis réveillé vers le haut et ne pouvait pas dormir, je travaillais sur ma solution. Il peut avoir travaillé si tordu un peu que j'ai jamais vraiment eu le temps de peaufiner ce bien. Voici le code que j'ai utilisé pour tester votre suggestion
PHP Code: [ Select ]
start
<?php
function check_y($word) {
// Make an array to return info
$return_array = array();
# Credits: Sergio Abreu
# Matches y followed by vowel in any place...
if( preg_match( "/y[aeiou]/i", $word)){
$return_array[$word] = 'consonant';
} elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
$return_array[$word] = 'vowel';
}
# To restrict y being the first letter, use ^ :
if( preg_match( "/^y[aeiou]/i", $word)){
$return_array[$word] = 'consonant';
} elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
$return_array[$word] = 'vowel';
}
// Return the return array
return $return_array;
}
echo '<pre>';
var_dump(check_text('Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
//check_text('Sylvia');
echo '</pre>';
function check_text($text) {
// Make sure we have text
if(empty($text)) {
// Kick back
return false;
}
// Break text into words
$text_array = explode(' ', $text);
// Make an array to return info
$return_array = array();
// Loop Text
for($i=0; $i<count($text_array); $i++) {
// Add to the return array
$return_array[] = check_y($text_array[$i]);
}
// Return the array
return $return_array;
}
?>
done
<?php
function check_y($word) {
// Make an array to return info
$return_array = array();
# Credits: Sergio Abreu
# Matches y followed by vowel in any place...
if( preg_match( "/y[aeiou]/i", $word)){
$return_array[$word] = 'consonant';
} elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
$return_array[$word] = 'vowel';
}
# To restrict y being the first letter, use ^ :
if( preg_match( "/^y[aeiou]/i", $word)){
$return_array[$word] = 'consonant';
} elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
$return_array[$word] = 'vowel';
}
// Return the return array
return $return_array;
}
echo '<pre>';
var_dump(check_text('Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
//check_text('Sylvia');
echo '</pre>';
function check_text($text) {
// Make sure we have text
if(empty($text)) {
// Kick back
return false;
}
// Break text into words
$text_array = explode(' ', $text);
// Make an array to return info
$return_array = array();
// Loop Text
for($i=0; $i<count($text_array); $i++) {
// Add to the return array
$return_array[] = check_y($text_array[$i]);
}
// Return the array
return $return_array;
}
?>
done
- start
- <?php
- function check_y($word) {
- // Make an array to return info
- $return_array = array();
- # Credits: Sergio Abreu
- # Matches y followed by vowel in any place...
- if( preg_match( "/y[aeiou]/i", $word)){
- $return_array[$word] = 'consonant';
- } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
- $return_array[$word] = 'vowel';
- }
- # To restrict y being the first letter, use ^ :
- if( preg_match( "/^y[aeiou]/i", $word)){
- $return_array[$word] = 'consonant';
- } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
- $return_array[$word] = 'vowel';
- }
- // Return the return array
- return $return_array;
- }
- echo '<pre>';
- var_dump(check_text('Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
- //check_text('Sylvia');
- echo '</pre>';
- function check_text($text) {
- // Make sure we have text
- if(empty($text)) {
- // Kick back
- return false;
- }
- // Break text into words
- $text_array = explode(' ', $text);
- // Make an array to return info
- $return_array = array();
- // Loop Text
- for($i=0; $i<count($text_array); $i++) {
- // Add to the return array
- $return_array[] = check_y($text_array[$i]);
- }
- // Return the array
- return $return_array;
- }
- ?>
- done
- Anonymous
- Bot


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Décembre 25th, 2012, 2:25 pm
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
Afficher de l'information
- Total des messages de ce sujet: 33 messages
- Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 161 invités
- Vous ne pouvez pas poster de nouveaux sujets
- Vous ne pouvez pas répondre aux sujets
- Vous ne pouvez pas éditer vos messages
- Vous ne pouvez pas supprimer vos messages
- Vous ne pouvez pas joindre des fichiers
