0
我想查找字符串內的特殊字符。這些元音是西班牙語的變音符號。該程序應該用帶有重音符號的字符串來統計元音。在西班牙語中,他們是áé,í,ó和ú。儘管我只是第一個4的球員。問題是我的代碼沒有檢測到特殊字符尋找特殊字符php
<?php
$string='maría';
$vocales = preg_match_all('/[aeiouáéíó]/i',$string,$matchesV);
echo "<br>vocales = $vocales";
if ((in_array('á',$matchesV))||(in_array('é',$matchesV)) || (in_array('í',$matchesV)) || (in_array('ó',$matchesV))){
$v = $vocales - 1;
echo "<br>v $v";
echo '<br>1'; }
?>
你應該使用http://php.net/manual/en/book .mbstring.php – 2014-09-06 17:32:14
只是一個提示:你可以在兩個數組中使用'in_array' - if(in_array(array('á','é','í','ó'),$ matchesV)){ – 2014-09-06 17:37:13