Hot answers tagged

3

Consider using concatenation: rather than $label_input_html = $label_input_html . ... use $label_input_html .= ... You're outputting HTML, so end $label_input_html with <br>, not \n. Also see the "\t", so if are you doing all that for display purposes, like to show your work, that's fine. I don't understand the END:. AFAIA that's completely ...


2

The way I see it, your whole process can be boiled down to this: <label for="country">** Select Country: </label> <?php $countries = file('countries.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!$countries) { echo '<input type="text" name="country" id="country" maxlength="40"...


2

Unless it is preferable to use fopen(), fgets(), fclose(), etc. - e.g. for the sake of performance, it could be simpler to use file_get_contents() to read all of the lines into memory and loop over the lines. It is extremely rare to see goto within PHP code. Idiomatic PHP code would simply use conditional blocks. Even the PHP documentation for goto contains ...


1

Hey Jonathan, welcome to Code Review! There's an easy way to turn those two maps into one. I'm going to tell you how, and give you some general tips as a bonus. Buckle up! ➰ Looping right round (like a record baby) You asked how to prevent yourself from repeating your loops, which is a perfect use case for a Fragment! Consider the following: <row> ...


1

The reset mechanism can probably be simplified. Instead of making it a submission button within your form, you can enjoy the same effect, by creating an <a href="">Reset</a> tag and styling identically to the other submit button. This way, when Reset is clicked, there will be no POST request and you can safely omit the 4 lines of code ...


Only top voted, non community-wiki answers of a minimum length are eligible