note 34594 modified in function.call-user-func-array by vrana

From: Date: Tue, 17 Aug 2004 14:53:53 +0000
Subject: note 34594 modified in function.call-user-func-array by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79938@lists.php.net to get a copy of this message
call_user_func_array() is nifty for calling PHP functions which use variable argument length. For example: <?php $array = array( array("foo", "bar"), array("bat", "rat"), ); $values = call_user_func_array("array_merge", $array); var_dump($values); ?> /* output: array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "bat" [3]=> string(3) "rat" } */ The neat feature is that $array could have any number of arrays inside it. --was-- call_user_func_array() is nifty for calling PHP functions which use variable argument length. For example: $array = array( array("foo", "bar"), array("bat", "rat"), ); $values = call_user_func_array("array_merge", $array); var_dump($values); /* output: array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "bat" [3]=> string(3) "rat" } */ The neat feature is that $array could have any number of arrays inside it. http://php.net/manual/en/function.call-user-func-array.php

« previous php.notes (#79938) next »