[wp-trac] [WordPress Trac] #58357: Blank foreach loop detected - Needs reformatting

WordPress Trac noreply at wordpress.org
Sat May 20 09:14:46 UTC 2023


#58357: Blank foreach loop detected - Needs reformatting
--------------------------+------------------------------
 Reporter:  mayur8991     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Formatting    |     Version:  6.2.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by nadimcse):

 I've checked the purpose of the foreach loop and from my perspective, we
 can use these two built-in functions
 {{{array_key_first()}}} and {{{reset()}}} instead of the foreach loop.

 Example:
 {{{#!php
 <?php
 $needle = array_key_first($replace_pairs);
 $replace = reset($replace_pairs);
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58357#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list