note 89923 added to control-structures.foreach

From: Date: Sun, 29 Mar 2009 05:46:32 +0000
Subject: note 89923 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-152573@lists.php.net to get a copy of this message
Appearently numerical keys are casted to int when looping with foreach. Example: $arr = array('10'=>'lol'); foreach ($arr as $k=>$v) { var_dump($k); } Output: int(10). This came unexpected to me. ---- Server IP: 128.39.198.38 Probable Submitter: 84.215.67.241 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/89923 Del: integrated -- https://master.php.net/note/delete/89923/integrated Del: useless -- https://master.php.net/note/delete/89923/useless Del: bad code -- https://master.php.net/note/delete/89923/bad+code Del: spam -- https://master.php.net/note/delete/89923/spam Del: non-english -- https://master.php.net/note/delete/89923/non-english Del: in docs -- https://master.php.net/note/delete/89923/in+docs Del: other reasons-- https://master.php.net/note/delete/89923 Reject -- https://master.php.net/note/reject/89923 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152573) next »