taith Posted February 1, 2008 Share Posted February 1, 2008 trying to pass dynamic function arguments from one function into another... <? function f($f){ $a=func_get_args(); unset($a[0]); return $f(implode(', ',$a)); } for($i=0; $i<20; $i++){ echo '<br>'.f(rr,'0'.rand(1,99999),4); } ?> which works all well and good... however, the ,4 is added onto the $a as tho it were part of the same string, and i want it segregated(second argument in my rr function).... any ideas? that'd output somin like 012195, 4 018554, 4 061523, 4 043335, 4 022405, 4 095647, 4 Link to comment https://forums.phpfreaks.com/topic/88829-solved-dynamic-function-arguments/ Share on other sites More sharing options...
Stooney Posted February 1, 2008 Share Posted February 1, 2008 The function f() only accepts 1 argument. You would need to add more. So if you want to do f(rr, '0'.rand(1,99999), 4) then you should declare the function like function f($arg1, $arg2, $arg3) Hope it makes sense Link to comment https://forums.phpfreaks.com/topic/88829-solved-dynamic-function-arguments/#findComment-455061 Share on other sites More sharing options...
taith Posted February 1, 2008 Author Share Posted February 1, 2008 yes and no... f() only recognizes one static argument... however, the $a=func_get_args(); returns ALL arguments... even if they were not declared... Link to comment https://forums.phpfreaks.com/topic/88829-solved-dynamic-function-arguments/#findComment-455248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.