从根本上讲-不。那简直就是简单。您可以将它改写得更短/更干净,但是想法是一样的。这就是我的写法:
$c = true; // Let's not forget to initialize our variables, shall we?foreach($posts as $post) echo '<div'.(($c = !$c)?' ':'').">$post</div>";
欢迎分享,转载请注明来源:内存溢出
从根本上讲-不。那简直就是简单。您可以将它改写得更短/更干净,但是想法是一样的。这就是我的写法:
$c = true; // Let's not forget to initialize our variables, shall we?foreach($posts as $post) echo '<div'.(($c = !$c)?' ':'').">$post</div>";
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)