Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#788189
Hi,

I have a code snippet which stores the tags and value in an array (indexed). Please see below:

<foo>Test</foo>

$data['foo'] = 'Test';

But when I store the tag which has attributes as mentioned below, it does not accept.

<foo order='1'>Test</foo>

Array: $data['foo'] = array('_'=>'Test','order'=>'1'); //Referred from forums

But it sets the attributes and not actual data for the tag.

Please help me in this, how to do this.

Thanks & Regards,
Julias
#788214
You need to create an array of arrays, like this:
Code: Select all
$data = array(
  'foo' => array(
      'order' => '1',
      'value' => 'Test 1'
   ),
  'bar'  => array(
      'order' => '2',
      'value' => 'Test 2'
   )
);
or like this:
Code: Select all
$data['foo'] = array(
      'order' => '1',
      'value' => 'Test 1'
);
Then you can access it like this:
Code: Select all
$value = $data['foo']['value'];
or like this
Code: Select all
foreach($data as $row) {
   $value = $row['value'];
}
#788219
Thank you amose.

I tried but the value for the tag is not set. The attribute has been set the tag but not actual value.

Please help.

Or help me how to formulate XML file in trigger.

I tried, the following but it throws errors:
Code: Select all
function prepareXMLRequest($data){
$xmlfile  = <<<XML
<soapenv:Envelope>
   <soapenv:Body>
      <own:add-owner-request>
     <own:add-owner>$data</own:add-owner>
      </own:add-owner-request>
   </soapenv:Body>
</soapenv:Envelope>
XML;
return $xmlfile;
}

		$profile	=	prepareXMLRequest($data);
		var_dump($profile);


ERRORS:
syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Please help me to formulate this in order to post this xml request from PM to third party service.

Regards,
Julias
#788252
The error is saying that you don't have matching " " (double quotation marks), so you probably forgot a " to close a string. It helps to post all your code, because I can't see what you have done wrong in setting your $data variable.

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]