Seriously, I'm not that bright. My whole life random stragners have taken pity on me. You only have to meet me once to see I am incapable of even dressing myself. I pass off as hip, but the truth is I just forgot to wear a belt. Here is my endless loop. Probably best not to run, it keeps freezing my PC $breed = rtrim(strtok($pet_spa, " \n")); $appointment = rtrim(strtok(" \n")); $day = rtrim(strtok(" \n")); $time = rtrim(strtok(" \n")); $charge = rtrim(strtok(" \n")); printf ("%9s\n", "Breed App. Day Time Charge"); while($breed){ echo $breed, " "; echo $appointment, " "; echo $day, " "; echo $time, " "; echo "\$" . number_format ($charge,2); } I have to use While. I know there are other ways of doing this. But can't I use While?
In your code, $breed is never modified. So if it contains any value equivalent to TRUE, that is where your infinite loop is coming from. You are essentially doing: while ( TRUE ) { echo "Yup, still true.\n"; } Perhaps you want your while to be if?
If you only want to iterate through the loop once use "if" for logic control. if $breed is initialized, like in the beginning of your script, your echo statements inside the loop will run. if($breed){ echo $breed, " "; echo $appointment, " "; echo $day, " "; echo $time, " "; echo "\$" . number_format ($charge,2); } Code (markup):
I don't think I can use if or any other variation of it since I'm getting the data from another file (include 'info.php') . Is ther anything I can do to just stop the loop? I need it structured this way to keep the variables for other manipulations
You are going to have to unset the variable $breed in order to complete the loop. The following will work for you, but this is not the real answer you need. If I knew more about what you are trying to accomplish in a larger picture, I could be of more help to you. while($breed){ echo $breed, " "; echo $appointment, " "; echo $day, " "; echo $time, " "; echo "\$" . number_format ($charge,2); $breed = ""; } Code (markup):