#28462 [Opn]: Cast array to properties of custom objects
| From: | bart at mediawave dot nl | Date: | Fri, 21 May 2004 09:59:54 +0000 |
| Subject: | #28462 [Opn]: Cast array to properties of custom objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59835@lists.php.net to get a copy of this message | ||
ID: 28462
User updated by: bart at mediawave dot nl
Reported By: bart at mediawave dot nl
Status: Open
Bug Type: Feature/Change Request
Operating System: Irrelevant
PHP Version: 5.0.0RC2
New Comment:
Another option is to simply add the array as a property to the custom
object. Then use __get() and __set() to simulate object properties with
the array.
Previous Comments:
------------------------------------------------------------------------
[2004-05-20 22:51:22] bart at mediawave dot nl
Description:
------------
A lot of functions in PHP return arrays in stead of objects. Of course
it's possible to simply cast the return value to an object like:
$urlObject = (object) parse_url($url);
But then I would get an instance of the stdClass. I can imagine
situations where people would like to cast arrays into properties of
their own custom objects. Maybe something like:
cast_array2object($array, $someCustomObject);
or something like:
$this .= (object) parse_url($url);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28462&edit=1