Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

this text:

Über <a href="[linkto:13]">allen</a> strahlt die <a  
href="[linkto:14]">Sonne</a> – <a href="[linkto:13]">über</a> allen in  
der Welt.

$num = count($linkto['1']);
echo $num;

Why i get only 1 and not 3 results?


Re: preg_match_all

Mark Knochen wrote:
Quoted text here. Click to load it
Quoted text here. Click to load it

You should have examined the match that was found, and then you would
have seen: that '.*' is greedy.  This means that the first 'linkto:' is
found and the the regular expression machine tries to use as many
characters as it can before it encounters the next one, which is the
**last** ']', hence only one match.

To get your three matches, you could replace '.*' with '.*?' which
makes the * non greedy.

Csaba Gabor from Vienna

Site Timeline