Edit report at https://bugs.php.net/bug.php?id=46977&edit=1

 ID:                 46977
 Comment by:         james dot cohen at gmail dot com
 Reported by:        michael at calwell-computing dot co dot uk
 Summary:            Extract() to work on data objects
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   All
 PHP Version:        5.3.0alpha3
 Block user comment: N
 Private report:     N

 New Comment:

You could get the behaviour that you want with:

extract(get_object_vars($carl), EXTR_PREFIX_ALL, 'carl');

if that helps


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to