Yes, the_lgel, you may specify an array for either ereg() and eregi() to place a pattern of matching values from your parse expression into. However, it's return value is an integer (not a string as Aeiri's post implies). The array of pattern matches will only be available if the ereg() or eregi() function first finds 'truth' in the match.
Consider the following chunk of code which I use to parse for (potentially) valid email addresses:
function PickEmailApart($v, $r=0) {
if($r > 3) {
$r = 0;
}
if(ereg("^([-a-zA-Z0-9_\\.\\+]+)@([-a-zA-Z0-9_]+)\\.([-a-zA-Z0-9_\\.]+)$", $v, $a)) {
return $a[$r];
}
return false;
}
When called, I can return either the entire email address (if no second argument is provided), or just the 'username' portion, or just the 'network
name' portion, or just the 'top level domain' portion. But I can only return one of those values if the first argument ($v) first matches the regular expression.
Fritz, if your code is as you've posted it (with those underscores in front of the variable name and the limit integer arguments), it won't work.
I ran my previously posted snippet on a string variable $text, which contained both more and less than 25 words and it worked fine. There's also no sense in assigning a new variable to $row['article'] just to run the explode() function on. Try this:
$words = explode(' ', $row['article'], 25);
From there, you can 'glue' the words back together like this:
$article = implode(' ', $words);
Have fun...