1

I am trying to make a soap request and it needs to have this structure

$requestBody=new sendDataExtraccionRequest(new sendDataExtraccionSubterranea("18-09-2020","00:02:01",1234567891,12345678.12,12345678.12),
                                           new sendDataExtraccionSubterranea("18-09-2020","00:03:01",1234567891,12345678.12,12345678.12));

thought that by creating an array with each object and then cast it should do, but getting an error on the soap call that the date field is missing

$array_datos[] = new sendDataExtraccionSubterranea("03-02-2021","00:02:01",1234567891,12345678.12,12345678.12);
$array_datos[] = new sendDataExtraccionSubterranea("03-02-2021","00:03:01",1234567891,12345678.12,12345678.12);

$requestBody=new sendDataExtraccionRequest( (object)$array_datos );

Also tried a solution that involved json encoding and decoding the array, but same error

Any hint on how to achieve it? Thanks

0

1 Answer 1

1

Use Spread Operator like this

$requestBody=new sendDataExtraccionRequest(...$array_datos);
Sign up to request clarification or add additional context in comments.

2 Comments

For information, "Argument unpacking" or "Splat operator" is available as of PHP 5.6
Great, this worked. Didn't know this existed on php, read about it on javascript. Thanks!

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.