I'm not sure if this is valid in php or not, but in C++ you can use the operator '%' to return a true of false value when dividing a number based on whether it results in a integer or a float; thus, if the number divided results in a whole number it returns 0; if there is a remainder, it returns 1.
Honestly I am still learning code myself (and I don't know php), but I think the function would look something like this:
for (i =1; i <= 10; i++)
{
if ( i % 2 == 1)
{
print i;
}
}
That should repeat the 'for' loop through values 1 -> 10, and if 'i' divided by 2 results in a float (0.5, 1.5, 2.5, etc) then the result of i%2 will be 1, thus printing i as a confirmed odd number. If it results in 0, it will repeat the process with the next increment of value i.
*edit*
I just tried this in C++ and it worked a charm, except that all the numbers were printed one after the other so it ended up with '13579'; that was easily fixed.
This is the C++ code:
for (int i =1; i <= 10; i++)
{
if ( i % 2 == 1)
{
std::cout << i << std::endl;
// std::cout tells it to print what follows '<<', and std::endl tells it to start a new line.
}
}