rhughes Posted August 14, 2009 Share Posted August 14, 2009 Here is the code: $client = new SoapClient( "xyz.wsdl" ); print ($client->getDocument("XGRRT2AMSU", "all", "avjx", array("all"), "ose")); Basically I need to pass this array - ["all"] as an argument, I copied it from a perl script but PHP is trying to find the value of "all", how can I pass the array as an argument? Many Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/ Share on other sites More sharing options...
.josh Posted August 14, 2009 Share Posted August 14, 2009 you can pass an array to a function in php just fine: function blah ($array) { echo "<pre>"; print_r($array); } $x = array('a','b','c'); blah($x); output: Array ( [0] => a [1] => b [2] => c ) are you sure you are passing it in the right place? what does your getDocument method look like? Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898126 Share on other sites More sharing options...
rhughes Posted August 14, 2009 Author Share Posted August 14, 2009 Here is the example Perl script (presumably correct as it was provided by the Web Department) that I was trying to convert to php: # Call the doSearch() method on the SOAP client. my $result = $soap->getDocument("B18U1T6JID", # Your SOAP key "all", # The name of the KB to use, $docid, # The docid of the KB document. ["all"], # The doc. domains we limit to. "ose"); # The audience we use for titles, etc. Here is the outline of the method: getDocument(string authKey, string whichKB, string docId, array domains, string audience) Return the document docId. whichKB is the domain class you need. domains is a list of strings, naming the domains you can use when accessing this document. audience is the group to whom this document is being presented. Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898162 Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 well assuming that the perl script and php script are the same, you should be able to pass an array in that function normally Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898164 Share on other sites More sharing options...
rhughes Posted August 14, 2009 Author Share Posted August 14, 2009 For example if I use this code: $x = array("all"); $client = new SoapClient( "xyz.wsdl" ); print ($client->getDocument("XGRRT2AMSU", "all", "avjx", $x, "ose")); I get the following error: Catchable fatal error: Object of class stdClass could not be converted to string Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898170 Share on other sites More sharing options...
wildteen88 Posted August 14, 2009 Share Posted August 14, 2009 It probably because your getDocument() method returns an object. So you cant place $client->getDocument(blah) within print(). Mayeb you want to use print_r Can we see your getDocument() method. Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898175 Share on other sites More sharing options...
rhughes Posted August 14, 2009 Author Share Posted August 14, 2009 print_r worked! Thank you so much for the help I have been banging my head against this problem for over a day now! Now I won't have to spend my weekend trying to figure out a solution. Quote Link to comment https://forums.phpfreaks.com/topic/170259-solved-need-to-pass-array-as-an-argument/#findComment-898177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.