| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 Patchespatch_6star (last revision 2010-09-03 16:51 UTC by info at 6stargrp dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2004-12-16 20:36 UTC] jsjohnst@php.net
  [2004-12-16 21:17 UTC] jsjohnst@php.net
  [2011-03-06 14:16 UTC] phuquangnam1 at gmail dot com
  [2011-04-01 17:43 UTC] varioseveral at gmail dot com
  [2022-01-29 12:53 UTC] aryasatvikkumar at gmail dot com
  [2024-02-18 20:47 UTC] rodiyansah406 at gmail dot com
  [2024-02-18 20:51 UTC] rodiyansah406 at gmail dot com
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 09:00:01 2025 UTC | 
Description: ------------ The foreach($array as $key) construct returns an array for $key, instead of just the key. This breaks many scripts that count on $key being a scalar (and well, the key). Reproduce code: --------------- $test = array(2, 3, 4, 5); foreach($test as $key){ print_r($key); } Expected result: ---------------- 2345 Actual result: -------------- Array ( [0] => 2 [1] => 0 ) Array ( [0] => 3 [1] => 1 ) Array ( [0] => 4 [1] => 2 ) Array ( [0] => 5 [1] => 3 )