|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-02-26 21:03 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2016-02-26 21:03 UTC] requinix@php.net
[2016-02-27 09:00 UTC] onskulis at yahoo dot de
[2016-02-27 09:06 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 19:00:01 2025 UTC |
Description: ------------ Cannot access array key with hyphen in it if passing a variable as key, but it works with string. Test script: --------------- <?php $test = array('customer-test1' => 1, 'customer-test2' => 2); function getPost($param) { global $test; echo $param." = ".$test[$param]."<br/>"; return isset($test[$param]) ? $test[$param] : NULL; } class Customer { private $test1; private $test2; function __construct() { } } $object = new Customer(); $arr = (array)$object; $newArr = array(); foreach($arr as $key => $val) { $newKey = str_replace(get_class($object), "", $key); $newArr[$newKey] = getPost(strtolower(get_class($object))."-".$newKey); }