Hello, I'm developing a website using expedias api. There are basically a lot of people in every room, and I wanted to echo the image of a little man for everyone. So for example, if I have 5 occupancies and I need to echo 5 tags with the little one as src. Any idea how to do this?
You should be interested in
str_repeat()
.Something like this should work:
Revisit this answer, a more efficient solution:
Assume the image is 12 pixels wide and 16 pixels tall - adjust to your needs.
This will generate a single element appropriately sized to display a
$repeat
copy of the image side by side.Suppose you store the number of people in a variable.
You can then insert that number into a
for loop
and have the program loop that number of times.You can read more about control structures here.