- preg_match_all: documentation ( source)
- in_array: documentation ( source)
<?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'; }