#44485 [Opn->Csd]: array_splice behaves unexpectedly when given an object as the last argument
| From: | ezyang@php.net | Date: | Thu, 20 Mar 2008 21:19:18 +0000 |
| Subject: | #44485 [Opn->Csd]: array_splice behaves unexpectedly when given an object as the last argument | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-619@lists.php.net to get a copy of this message | ||
ID: 44485
Updated by: ezyang@php.net
Reported By: computerlov at yahoo dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: windows xp
PHP Version: 5.2.5
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2008-03-20 16:35:38] computerlov at yahoo dot com
Just checked it on my machine.
worked exactly as expected.
Instead of passing the $object as a parameter to array_splice, I passed
array($object). Then the object itself replaced the others in the array
and not its data members.
Thank you.
------------------------------------------------------------------------
[2008-03-20 14:02:23] felipe@php.net
Yes, exactly.
------------------------------------------------------------------------
[2008-03-20 13:44:36] computerlov at yahoo dot com
so If i do this
$arr = array($oSomeObject);
array_splice(..., 0, 2, $arr);
will it work as I intended?
I'll check that later.
------------------------------------------------------------------------
[2008-03-20 11:02:39] felipe@php.net
The documentation describe the fourth parameter as array, but the
correct is mixed.
Reclassified as Documentation problem.
------------------------------------------------------------------------
[2008-03-20 10:58:03] felipe@php.net
> I just noticed something you did wrong when reproducing the bug:
> the error is on the array we splice and not the output.
Oh, ok!
> instead of getting an array of 9 objects, you get
> an array of 8 objects and all the data members of
> CSomeClass in the array.
The data of 'replacement' parameter is converted to array, then, the
object is converted to an array of their properties. This is expected.
Thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/44485
--
Edit this bug report at http://bugs.php.net/?id=44485&edit=1