Mailinglisten-Archive |
Konstantin Rekk schrieb:
> dass mit implode() ein String zusammengebaut werden kann, ist geläufig.
> Wenn man aber das Zusammenkleben an eine Bedingung knüpft, dann wird man wohl
> um eine Schleife nicht herumkommen (oder?).
>
> <code>
> $and="";
> foreach( $conditions as $condition ) {
> $string .= !empty($condition) ? $and . $condition : "" ;
> $and = " and ";
> }
> </code>
>
> Frage: was ist eurer Erfahrung nach schneller, gibt es bessere Möglichkeiten?
$conditions = array_filter($conditions);
$string = '"' . implode('" AND "', $conditions) . '"';
--
Sebastian Mendel (www.sebastianmendel.de)
*www.warzonez.de* | www.tekkno4u.de | www.nofetish.com
php::bar PHP Wiki - Listenarchive