Req #46977 [Opn->Fbk]: Extract() to work on data objects
| From: | levim@php.net | Date: | Wed, 16 Apr 2014 22:57:04 +0000 |
| Subject: | Req #46977 [Opn->Fbk]: Extract() to work on data objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185309@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46977&edit=1
ID: 46977
Updated by: levim@php.net
Reported by: michael at calwell-computing dot co dot uk
Summary: Extract() to work on data objects
-Status: Open
+Status: Feedback
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: All
PHP Version: 5.3.0alpha3
Block user comment: N
Private report: N
New Comment:
Given the simple work-around is this something you are interested in pursuing farther?
Previous Comments:
------------------------------------------------------------------------
[2012-02-25 02:20:41] james dot cohen at gmail dot com
You could get the behaviour that you want with:
extract(get_object_vars($carl), EXTR_PREFIX_ALL, 'carl');
if that helps
------------------------------------------------------------------------
[2008-12-30 20:54:52] michael at calwell-computing dot co dot uk
Description:
------------
extract() currently only extracts arrays into variables.
I think it would be good to be able to extract data objects too.
Reproduce code:
---------------
e.g.
$car1->wheels = 4;
$car1->horsepower = 40;
$car1->seats = 2;
extract($car1, EXTR_PREFIX_ALL, 'car1');
/*
$car1_wheels = 4
$car1_horsepower = 40
...
*/
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46977&edit=1