To loop over a list of users in PHP, you can use the foreach loop to iterate over each element of an array containing the user information. Here's an example:
main.php340 chars12 lines
In this example, we first define an array of users, where each user is represented as an array containing their name and email. We then use the foreach
loop to iterate over each user in the array and output their name and email. The loop assigns the current user to the $user
variable on each iteration, which we can then access using array syntax ($user["name"]
and $user["email"]
). The output of this code would be:
main.php106 chars4 lines
gistlibby LogSnag