Nathan Riley
asked on
PHP Loop with Counts
I'm needing help with logic on my PHP loop.
So I have user input that comes in the form of a number anything between 18 and 100. They are $agemin and $agemax. Based on their values I dynamically create bit of code. I need some help with the logic. Below is an example.
My output of $population based on the above example would be:
+ age18 + age19 + age20 + age21 + age22 + age23 + age24
So I have user input that comes in the form of a number anything between 18 and 100. They are $agemin and $agemax. Based on their values I dynamically create bit of code. I need some help with the logic. Below is an example.
$agemin = 18;
$agemax = 24;
Not sure which, but need a php loop here I assume
$population .= ' + age'.$ageCount;
My output of $population based on the above example would be:
+ age18 + age19 + age20 + age21 + age22 + age23 + age24
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah, didn't see your message before I accepted, sorry ray.
NP, there are often many ways to get to the same solution. Best regards, ~Ray
http://iconoun.com/demo/temp_nathan_riley.php
Outputs: string(56) " + age18 + age19 + age20 + age21 + age22 + age23 + age24"
Open in new window