Hi all!
I'm sorry if my question is silly for you, but I'm a novice with XML: after parsing my XML, i obtain a result like this:
Array ( [KEY_VALUE] => [KEY] => MSISDN [VALUE] => +393495094150 ) Array ( [KEY_VALUE] => [KEY] => ContentId [VALUE] => 25877 )
Is there a manner to assign values to respective variables?
I would like to have:
<?php
$msisdn = +393495094150;
$contentid = 25877;
?>
Thanks in advance and sorry for my poor english.
Davide.
Hello Davide,
I understand what you are trying to do here. If you want to get $msisdn and $contentid into global variables to use later in your script you would need to do something like this:
<?php
require("MagicParser.php");
// create a global array to extract the key value pairs
$values = array();
function myRecordHandler($record)
{
global $values;
$key = $record["KEY"];
$value = $record["VALUE"];
$values[$key] = $value;
}
// your normal call to MagicParser_parse - replace this with what you are currently using
MagicParser_parse(...);
// here, you can either use the values directory, for example:
print $values["MSISDN"];
// alternatively, you can assign each value to its own variable:
$msisdn = $values["MSISDN"];
$contentid = $values["ContentId"];
?>
Hope this helps!
Cheers,
David.