Pass associative arrays in call_user_func_array(...)
Posted
by Matt
on Stack Overflow
See other posts from Stack Overflow
or by Matt
Published on 2010-03-31T13:08:17Z
Indexed on
2010/03/31
13:13 UTC
Read the original article
Hit count: 344
php
|templating
Hey all,
I'm building a templating system and I'm running in to an issue with calling functions on the fly.
When I try the following:
$args = array(
4,
'test' => 'hello',
'hi'
);
You know.. some numerical elements some associative elements,
call_user_func_array($function, $args);
converts the array to something like this:
$args = array(
4,
'hello',
'hi'
);
Is there any way around this other than passing an array like this:
$args = array(
4,
array('test' => 'hello'),
'hi'
);
Thanks! Matt
© Stack Overflow or respective owner