The code displays the numbers as expected:

<?$sticker = ""; if (array_key_exists("PROPERTIES", $arResult) && is_array($arResult["PROPERTIES"])) { foreach (Array("STOCK" => "Акция", "INFICTION"=>"") as $propertyCode => $propertyCodeName) if (array_key_exists($propertyCode, $arResult["PROPERTIES"]) && intval($arResult["PROPERTIES"][$propertyCode]["PROPERTY_VALUE_ID"]) > 0) { $arFiltrum = $arResult["PROPERTIES"]['INFICTION']["VALUE_XML_ID"]; if($propertyCode == "STOCK") $sticker .= '<span class="xit" style="font-size:20px;"'; if(in_array("INF1",$arFiltrum)) $sticker .= "1"; if(in_array("INF2",$arFiltrum)) $sticker .= "2"; if(in_array("INF3",$arFiltrum)) $sticker .= "3"; if(in_array("INF4",$arFiltrum)) $sticker .= "4"; if(in_array("INF5",$arFiltrum))$sticker .= "5"; $sticker .= '>'.$propertyCodeName.'</span>'; } } ?> 

The value in each (in_array("INF1-INF5",$arFiltrum)) is true . But if I insert instead of numbers, I try to insert pictures

 $sticker .= '<span class="xits" style="font-size:20px; background: url(/tamp.png) 1px -1px no-repeat;left:70px;"'; $sticker .= '<span class="xits" style="font-size:20px; background: url(/gravirovka.png) 1px -1px no-repeat;"'; $sticker .= '<span class="xits" style="font-size:20px; background: url(/uf_print.png) 1px -1px no-repeat;"'; $sticker .= '<span class="xits" style="font-size:20px; background: url(/sticker.png) 1px -1px no-repeat;"'; $sticker .= '<span class="xits" style="font-size:20px; background: url(/label.png) 1px -1px no-repeat;"'; 

That only displays the first picture. Problems with styles disappear, because without conditions all pictures are displayed normally.

  • “Condition does not work” - do you mean that the if in PHP does not work correctly? - VladD
  • I mean that the condition does not work in my code, maybe someone will notice an error that I do not see. - Nikolay
  • @Nikolay, at least to ask ru.SO users to work with code parsers is at least not polite. - Dmitriy Simushev
  • @Dmitriy Simushev I ask for help, not analyzers. Because I do not understand where is the error. - Nikolay
  • one
    @Nikolay take the debugger and see how your code works ... - Vladimir Martyanov

1 answer 1

 if($propertyCode == "STOCK") $sticker .= '<span class="xit" style="font-size:20px;"'; if(in_array("INF1",$arFiltrum)) $sticker .= "1"; if(in_array("INF2",$arFiltrum)) $sticker .= "2"; if(in_array("INF3",$arFiltrum)) $sticker .= "3"; if(in_array("INF4",$arFiltrum)) $sticker .= "4"; if(in_array("INF5",$arFiltrum))$sticker .= "5"; $sticker .= '>'.$propertyCodeName.'</span>'; 

Here you have an error. First, even numbers are added to > , that is, they are not inside the elements, but among the attributes. Secondly, if you add

 $sticker .= '<span class="xits" style="font-size:20px; background: url(/tamp.png) 1px -1px no-repeat;left:70px;"'; 

Then do it 5 times, and close the tag only 1 time. It is necessary to close the tag every time and in the beginning it is better to immediately write

 if($propertyCode == "STOCK") $sticker .= '<span class="xit" style="font-size:20px;">'; 

From the closing > .