Req #75908 [NEW]: unset do not work
| From: | novoyura2 at gmail dot com | Date: | Fri, 02 Feb 2018 14:05:18 +0000 |
| Subject: | Req #75908 [NEW]: unset do not work | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213782@lists.php.net to get a copy of this message | ||
From: novoyura2 at gmail dot com
Operating system: ubuntu
PHP version: 5.6.33
Package: Arrays related
Bug Type: Feature/Change Request
Bug description:unset do not work
Description:
------------
Cant get element by key after transform object to array
Test script:
---------------
$a = [0 => 1, 1=>3, 2=> 6];
print_r($a);
$o = new stdClass();
foreach($a as $key => $value){
$o->$key = $value;
}
$a = (array)$o;
print_r($a);
foreach ($a as $key => $id) {
unset($a[$key]);
}
print_r($a);
Expected result:
----------------
Array ( [0] => 1 [1] => 3 [2] => 6 ) Array ( [0] => 1 [1] => 3 [2] => 6
) Array()
Actual result:
--------------
Array ( [0] => 1 [1] => 3 [2] => 6 ) Array ( [0] => 1 [1] => 3 [2] => 6
) Array ( [0] => 1 [1] => 3 [2] => 6 )
--
Edit bug report at https://bugs.php.net/bug.php?id=75908&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75908&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75908&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75908&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75908&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75908&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75908&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75908&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75908&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75908&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75908&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75908&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75908&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75908&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75908&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75908&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75908&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75908&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75908&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75908&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75908&r=mysqlcfg