Mailinglisten-Archive |
Marcel Kurz wrote:
> Hallo Liste,
> innerhalb von preg_replace funktioniert (!stristr("$1","?")? "?" : "&")
> nicht. Warum?
>
> Hier mein kompl. Testcode:
>
> $text = '
> <a href="foo.php">link1</a><br>
> <a href="foo.php?foo=bar">link2</a><br>';
>
> $suchmuster = '/href="(.*?)"/is';
> $text = preg_replace($suchmuster, "/href=\"$1".(!stristr("$1","?")? "?" :
> "&")."foo2=bar2\" ", $text);
>
>
>
> Wenn ich das nicht innerhalb von preg_replace aufrufe funktioniert es:
> echo (!stristr("foo.php?foo=bar","?")? "?" : "&");
> echo (!stristr("foo.php","?")? "?" : "&");
>
>
> Wer hat ein Tip für mich...
Sei mal etwas weniger sparsam mit Klammen...:
"bla".((bedingung)?1:2)."bla"
>
> Beste Grüße
> Marcel
Yannik
php::bar PHP Wiki - Listenarchive