【发布时间】:2018-07-30 10:16:54
【问题描述】:
给我一个句子,我必须找出至少包含 2 个元音的单词并打印出来。 有人可以告诉我我所做的是对还是错? preg_match('/[aeiou].*[aeiou]/') 这适用于所有单词吗?
<?php
$line = $_POST["input"];
$array = preg_split("/\s+/", $line);
//our line has been separated into Strings
for($i = 0; $i<sizeof($array); $i++)
{
if(preg_match('/[aeiou].*[aeiou]/', $array[$i], $matches))
{
print($array[$i]." ");
}
}
?>
我输入的html文件是:-
<html>
<head>
<title>My web page</title>
</head>
<body>
<form action="test.php" method="post">
Enter the sentence <br><br>
<input type="text" name="input" ><br><br>
<input type="submit" value="Submit" >
</form>
</body>
</html>
【问题讨论】:
-
这不是您在 SO 上提问的方式。看到这个:stackoverflow.com/help/how-to-ask