There was a problem. From the database comes the name of the image in the array, but when I call in Smatry, I only get the first letter of the file name, help solve the problem.

Code below

{foreach from=$rooms key=id item=val} <div class="rooms_content"> <h3 id="h3-options">Что включено:</h3> {foreach from=$val["optImagesA"] key=k item=v} <img src="./static/images/iconoptions/{$v.optImages}"/> {/foreach} <p>{$val.rooms} <a> Забронировать </a></p> </div> {/foreach} 

Debug smarty

 $rooms Origin: "Smarty object" Value Array (2) 0 => Array (9) 0 => "4" id => "4" 1 => "80" hotelsid => "80" 2 => "Комната 1" rooms => "Комната 1" 3 => "icon1.png" optImages => "icon1.png" optImagesA => Array (1) 0 => "icon1.png" 1 => Array (9) 0 => "6" id => "6" 1 => "80" hotelsid => "80" 2 => "Room 2" rooms => "Room 2" 3 => "icon2.png,icon6.png" optImages => "icon2.png,icon6.png" optImagesA => Array (2) 0 => "icon2.png" 1 => "icon6.png" 

How does the value come

 <img src="./static/images/iconoptions/i"/> 

Thank you in advance for your help.

  • In smarty it is not strong, but you choose $ val ["optImagesA"] in $ k and $ v where $ v is a string and you work with it as with an array. - fens
  • @fens I even tried {$ v ["optImages"]}, but the result is the same ( - Pavel
  • You just need to substitute $ v in uri without specifying any indexes - fens
  • @fens Thank you kind person God bless you)). - Pavel
  • one
    Advice for the future, when you write code, do not abbreviate the names of variables, like $ k, $ v, $ id, $ val, for example, in your case, you can $ id = $ roomIndex, $ val = $ roomItem, $ k = $ imageIndex, $ v = $ imageName this will help avoid such errors. - fens

0