0

I can't pass array and string as parameter in a variable.

Following is my code which is not working as expected.

$wsdlParams = array(
        array(     
            'webserviceid' => $WebServiceID,
            'webservicepass' =>  $WebServicePassword
        ),$fde);

    $soapclient = new SoapClient($WebServiceURL);
    $soapresult = $soapclient->MyInfo($wsdlParams);

Working One:

$soapclient = new SoapClient($WebServiceURL);
$soapresult = $soapclient->MyInfo(array('webserviceid' => $WebServiceID,'webservicepass' => $WebServicePassword),$fde);

1 Answer 1

1

You need to use the ... (splat) operator to expand your array of parameters into the necessary two arguments for myInfo:

$soapresult = $soapclient->MyInfo(...$wsdlParams);
Sign up to request clarification or add additional context in comments.

2 Comments

I didn't know anything about splat... its work great. thanx. is there any other solution?
@UFO you could use $soapresult = $soapclient->MyInfo($wsdlParams[0], $wsdlParams[1]); but the splat operator is a much nicer way of writing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.