I\'m not good with regex but i want to use it to extract words from a string.
The words i need should have minimum 4 characters and the provided string can
Explode your string with spaces (which will create an array with all words), then check if the word is bigger than 4 letters.
//The string you want to explode
$string = "Sus azahares presentan gruesos pétalos blancos teñidos de rosa o violáceo en la parte externa, con numerosos estambres."
//explode your $string, which will create an array which we will call $words
$words = explode(' ', $string);
//for each $word in $words
foreach($words as $word)
{
//check if $word length if larger then 4
if(strlen($word) > 4)
{
//echo the $word
echo $word;
}
}
strlen();
strlen — Get string length
explode();
explode — Split a string by string