I have an XML that looks like this. I've loaded it into a string in PHP:
<sense>
<gloss>there</gloss>
<gloss>over there</gloss>
<gloss>that place</gloss>
<gloss>yonder</gloss>
</sense>
<sense>
<gloss>that far</gloss>
<gloss>that much</gloss>
<gloss>that point</gloss>
</sense>
I'm trying to format it to look like this:
<sense>
<gloss>there|over there|that place|yonder&that far|that much|that point</gloss>
</sense>
I've managed to almost do this with this code: (There's probably a smarter way to to this but still...)
preg_match_all('~<gloss>(.*)</gloss>~sU', $input, $matches);
$newStr = '';
//Add all new matches and put them in a new string
for ($i=0; isset($matches[1][$i]); $i++)
{
$newStr .= $matches[1][$i].'|';
}
But how would I separate the two different sense fields with a "&" (or any separating mark)?