note 73738 deleted from function.array-splice by felipe
| From: | felipe@php.net | Date: | Sat, 05 Jan 2008 02:09:17 +0000 |
| Subject: | note 73738 deleted from function.array-splice by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134821@lists.php.net to get a copy of this message | ||
Note Submitter:
----
<?
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))?>