php - is it possible to pass parameters to an assoc array? -
think array this:
... "key1" => some_call("val1", $params), "key2" => some_call("val1", $params), ...
now want pass parameters ($params) when addressing array entries
$x = $array['key1'] , $params ...
is there way this?
update
why this? using codeigniter , in language file assoc array, right side holds text in predicted language. want abuse little bit , want load email templates, pass parameter holds values shell replaced in template.
update 2
for php 5.2.*
since php 5.3 can use anonymous functions. maybe want this:
<?php function some_call($arg,$params) { echo "$arg: ",count($params),"\n"; } $array = array( 'key1' => function($params) { some_call('val1',$params); }, 'key2' => function($params) { some_call('val1',$params); } ); $array['key1'](array(1,2,3));
Comments
Post a Comment