note 107995 added to function.array-push
| From: | Chicna | Date: | Wed, 21 Mar 2012 10:14:17 +0000 |
| Subject: | note 107995 added to function.array-push | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186751@lists.php.net to get a copy of this message | ||
I found a simple way to have an "array_push_array" function, without the references
problem when we want to use call_user_func_array(), hope this help :
function array_push_array(array &$array)
{
$numArgs = func_num_args();
if(2 > $numArgs)
{
trigger_error(sprintf('%s: expects at least 2 parameters, %s given', __FUNCTION__,
$numArgs), E_USER_WARNING);
return false;
}
$values = func_get_args();
array_shift($values);
foreach($values as $v)
{
if(is_array($v))
{
if(count($v) > 0)
{
foreach($v as $w)
{
$array[] = $w;
}
}
}
else
{
$array[] = $v;
}
}
return count($array);
}
----
Server IP: 195.221.21.36
Probable Submitter: 87.88.212.169
----
Manual Page -- http://www.php.net/manual/en/function.array-push.php
Edit -- https://master.php.net/note/edit/107995
Del: integrated -- https://master.php.net/note/delete/107995/integrated
Del: useless -- https://master.php.net/note/delete/107995/useless
Del: bad code -- https://master.php.net/note/delete/107995/bad+code
Del: spam -- https://master.php.net/note/delete/107995/spam
Del: non-english -- https://master.php.net/note/delete/107995/non-english
Del: in docs -- https://master.php.net/note/delete/107995/in+docs
Del: other reasons-- https://master.php.net/note/delete/107995
Reject -- https://master.php.net/note/reject/107995
Search -- https://master.php.net/manage/user-notes.php