![]() How can this be done in a more efficient manner? I thought about fetching four different sets from the database, meaning 4 different queries, would that be more efficient? I'm thinking it could be done with one loop but but I can't come up with a solution. So, this means that if I have 1000 entries in the table and 4 different status' that can be checked, it means that there will be 4 loops, each one executing 1000 times. For example: have this PHP code to implement this ($recipients contains an associative array of the db table): We will first look at how the foreach() function works on an indexed array. From the official PHP website: Generators provide an easy way to implement simple iterators without the overhead or complexity of implementing a class that implements the Iterator interface. We will learn in turn how the PHP foreach function works on both these types of arrays. I need to convert the data into the following XML, depending on the status field. As we learned in the Syntax of PHP foreach() section above, the foreach function can work on both indexed and associative arrays. 1 Syntax of PHP foreach (): 2 Code & Explanation: 2.1 PHP Foreach () on Indexed arrays: 2.2 PHP Foreach () on an associative array: 2.3 Php Nested Foreach On Multi Dimensional Array 2.4 Find the foreach index 2.5 Count number of iterations in a foreach loop 2.6 Remove an array element in a foreach loop 2. I have a table Recipients in MySQL structured like this: id | email | status I just couldn't think of a title that could describe my problem. ![]() ![]() First off, I know the title is generic and not fitting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |