Sfoglia il codice sorgente

Do not iterate by reference

Iteration by reference is generally only used when the variable is
changed and that change should be reflected in the array. Whether
this is faster or not is irrelevant since this is a realistic
implementation.
Levi Morrison 9 anni fa
parent
commit
276ddaaf86
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      frameworks/PHP/php/fortune.php

+ 1 - 1
frameworks/PHP/php/fortune.php

@@ -30,7 +30,7 @@ asort($arr);
 <th>message</th>
 <th>message</th>
 </tr>
 </tr>
 <?php
 <?php
-foreach ( $arr as $id => &$fortune ) {
+foreach ( $arr as $id => $fortune ) {
 ?>
 ?>
 <tr>
 <tr>
 <td><?php echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8'); ?></td>  
 <td><?php echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8'); ?></td>