473,503 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trivial arguments function

hi all

i've a function F as

function F($arg1,$arg2,$arg3){
....
}

and a variable $args = "A,B,C"

my goal is to call the function with the content of $args.

if i call f($args) i call this function with 1 argument : an array, i
wish call function as f(A,B,C)

If Someone thinks this is possible... please give me the code ;))

regards.

Jul 13 '06 #1
2 1242
jh****@gmail.com wrote:
hi all

i've a function F as

function F($arg1,$arg2,$arg3){
...
}

and a variable $args = "A,B,C"

my goal is to call the function with the content of $args.

if i call f($args) i call this function with 1 argument : an array, i
wish call function as f(A,B,C)

If Someone thinks this is possible... please give me the code ;))

regards.
f($args[0]. $args[1], $args[2]);

Or -
f($arg1, $arg2=null, $arg3=null) {
if (is_array($arg1) && $arg2==null && $arg3 == null) {
if (count($arg1) == 3)
$arg2 = $arg1[1];
$arg3 = $arg1[2];
$arg1 = $arg1[0];
}
else {
echo "Insufficient number of parameters passed<br>\n";
exit();
}
}
... rest of stuff here
}

Of course you should do other checking to ensure you're passing 3
arguments in the array.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 13 '06 #2

jh****@gmail.com wrote:
hi all

i've a function F as

function F($arg1,$arg2,$arg3){
...
}

and a variable $args = "A,B,C"

my goal is to call the function with the content of $args.

if i call f($args) i call this function with 1 argument : an array, i
wish call function as f(A,B,C)

If Someone thinks this is possible... please give me the code ;))

regards.
call_user_func_array('F', explode(',' $args));

Jul 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2415
by: Chuck Anderson | last post by:
I have a function with 7 inputs. The last three have default values. I want to call that function specifying the first four, skip two and then specify the last. I thought I could write this...
9
3782
by: Matt Eberts | last post by:
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as...
5
1838
by: William Payne | last post by:
Hello, consider the following two classes (parent and child): #ifndef SINGLETON_HPP #define SINGLETON_HPP #include <cstddef> /* NULL */ template <typename T> class Singleton {
6
4000
by: Melkor Ainur | last post by:
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed...
21
4086
by: dragoncoder | last post by:
Consider the following code. #include <stdio.h> int main() { int i =1; printf("%d ,%d ,%d\n",i,++i,i++); return 0; }
41
2497
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum +=...
9
16792
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
7
1927
by: sfeher | last post by:
Hi All, Is there a way to preserve the arguments across functions? I have: <script> function myFirstFunction() { // arguments = 'param1'
2
12496
ADezii
by: ADezii | last post by:
When a call is made to a Sub or Function Procedure, you can supply Arguments in the exact order they appear in the Procedure's definition, or you can supply them in any position by name. To...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.