如果我是某个数字,请更改classname [英] Change classname if i is a certain number
本文介绍了如果我是某个数字,请更改classname的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ i = 1;
foreach($ properties ['blocks'] as $ block)
{
echo'< div class =colum1id =pic'。$ i。'style =背景图像:网址(/上传/ overige /'.$块[ 'IMAGE2']'。);>
有没有办法做到这一点? colum1需要变成colum2。
$ c> $ i = 1;foreach($ properties ['blocks'] as $ block)
{
echo'< div class ='。($ i< 4?'colum1':'colum2' )。'id =pic'。$ i。'style =background-image:url(/ uploaded / overige /'.$ block ['image2']。');>
// --------------
Im looking for a way to change the number in a class if i=4 or higher.
$i=1;
foreach($properties['blocks'] as $block)
{
echo '<div class="colum1" id="pic'.$i.'" style="background-image:url(/uploaded/overige/'.$block['image2'].');">
Is there any way to do this ? colum1 needs to become colum2. i've been trying to use things like if else etc. but so far no success.
解决方案
$i = 1;
foreach($properties['blocks'] as $block)
{
echo '<div class="' . ($i < 4 ? 'colum1' : 'colum2') . '" id="pic'.$i.'" style="background-image:url(/uploaded/overige/'.$block['image2'].');">
// --------------
这篇关于如果我是某个数字,请更改classname的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文