-
Posts
5 -
Joined
-
Last visited
Never
Posts posted by manianprasanna
-
-
Thanks for all those who replied.
I would like to tell one more thing. The statemets inside the looping function is not same in all the case. I can be anything like conditional statements, DB manupulations, etrc....The loop function should take those statements as input and loop it.
case 1:
[code]
loop(10) {
//some set of statements.
}
[/code]
case 2:
[code]
loop(10) {
//Not the same set of statements as in case 1.
}
[/code]
-
Yes that's what i would like to know that only., that is how to define the function loop to accomplish the functionality said in my previous post.
[quote]Thanks for those who had replied so far, but those are not the answers i want. Because as i already said that i want to looping statment.To explain more clear, see the below code
[code]
loop(10) {
for($i=0; $i<5; $i++) {
echo 'please help me';
}
}
[/code]
The same loop function should also be able to use like below
[code]
loop(10) {
if($i==8) {
echo 'please help me';
}
}
[/code]
I think now you all can understand more clear. To accomplish this type of function calling how should i declare the loop function.[/quote] -
Thanks for those who had replied so far, but those are not the answers i want. Because as i already said that i want to looping statment.To explain more clear, see the below code
[code]
loop(10) {
for($i=0; $i<5; $i++) {
echo 'please help me';
}
}
[/code]
The same loop function should also be able to use like below
[code]
loop(10) {
if($i==8) {
echo 'please help me';
}
}
[/code]
I think now you all can understand more clear. To accomplish this type of function calling how should i declare the loop function. -
I would like to write a looping function. for example as below
[code]
loop(10) {
echo 'Please answer me';
}
[/code]
So that the above code would print 10 times ''Please answer me''. Actually the code looks similar to for loop, but the above code is not the actual functionality i need. The functionality i need is similar to the above code. So could anyone tell me that whether i can write a looping function. If yes then how?
Please help me.
To write a looping function
in PHP Coding Help
Posted
Example 1:
[code]
loop(10) {
////MySQL insert statements.
}
[/code]
Example 2:
[code]
loop(10) {
////Some simple echo statemets.
}
[/code]
Example 2:
[code]
loop(10) {
////Some file manupulations.
}
[/code]
Sorry if i have hurted any body..
Please reply me.
[quote author=hostfreak link=topic=107212.msg429820#msg429820 date=1157632212]
With my function, you can change what is looped and how many times, for example:
[code]
<?php
function loop($times, $text) {
for ($i = 0; $i < $times; $i++) {
echo "$text<br />";
}
}
loop(10, "Please answer me"); //Please answer me - looped 10 times
loop(8, "Hello, how are you"); //Hello, how are you - looped 8 times
//You could apply statements like:
$test = "8";
if ($test == "8") {
loop(5, "Test equals 8");
}
?>
[/code]
[/quote]