I have this problem,
I need php to recognise if the word is ending with one of these letters, that are declared as an array
$vocals = array ('a', 'e', 'i', 'o', 'u');
And if it is, to ECHO "for ex. this word ends with a vocal.
I spent two days in figuring out what the code should be, but no success, and I looked several times in the manual - but still don't get it
If possible I would need the code, please.
preg_match - Can't get it - how it works
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
regular expressions can do this fairly easy..
Code: Select all
<?php
$vocals = array('a', 'e', 'i', 'o', 'u');
$num_matches = preg_match_all('#\b.*?ї' . implode('',$vocals) . ']\b#i',$text,$matches);
var_dump($num_matches, $matches);
?>