Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat image x number of times

Tags:

loops

php

image

Hello I am working on a site that uses expedias api. Basically I get a number of people per room, and I want to echo out a little man image for each person. So if I have occupancy of 5 for example and I need to echo 5 tags with the little man as a src. Any idea how to do this??

like image 260
luv2code Avatar asked Dec 05 '25 08:12

luv2code


1 Answers

Well let's say you have the amount of people stored in a variable.

$occupancy = 5;

You can then plug in that number into a for loop, and have the program cycle through that many times.

for($n = 0; $n < $occupancy; $n++) {
  // Disco
}

You can read more about control structures here.

like image 61
Jon McIntosh Avatar answered Dec 07 '25 22:12

Jon McIntosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!