note 73738 added to function.array-splice
| From: | php-general at lists dot php dot net | Date: | Thu, 08 Mar 2007 11:58:27 +0000 |
| Subject: | note 73738 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124231@lists.php.net to get a copy of this message | ||
<?
class _test
{
public $first='test::1';
public $second='test::2';
}
$array=array(1,2,3,4,5);
echo '<pre>',var_Dump($array),'</pre>';
/* output:
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
}
*/
array_Splice($array,3,0,new _test);
echo '<pre>',var_Dump($array),'</pre>';
/* output:
array(7) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
string(7) "test::1"
[4]=>
string(7) "test::2"
[5]=>
int(4)
[6]=>
int(5)
}
*/
?>
lesson: array_Splice (and maybe more others functions) takes objects like arrays
advice: close object in array
<?array_Splice($array,$x,0,array($object))?>
----
Server IP: 212.24.129.110
Probable Submitter: 81.19.5.135
----
Manual Page -- http://www.php.net/manual/en/function.array-splice.php
Edit -- https://master.php.net/note/edit/73738
Del: integrated -- https://master.php.net/note/delete/73738/integrated
Del: useless -- https://master.php.net/note/delete/73738/useless
Del: bad code -- https://master.php.net/note/delete/73738/bad+code
Del: spam -- https://master.php.net/note/delete/73738/spam
Del: non-english -- https://master.php.net/note/delete/73738/non-english
Del: in docs -- https://master.php.net/note/delete/73738/in+docs
Del: other reasons-- https://master.php.net/note/delete/73738
Reject -- https://master.php.net/note/reject/73738
Search -- https://master.php.net/manage/user-notes.php