I have this foreach statement:
foreach ($googlebasemap as $key => $linkdata) {
$xmlmap['item.' . count($xmlmap)] = array('title.0' => $linkdata['title'],
'link.0' => $linkdata['link'] . '?source=googlebase',
'description.0' => $linkdata['desc'],
'g:price.0' => $linkdata['price'],
'g:id.0' => $linkdata['id'],
'g:model_number.0' => $linkdata['prodnum'],
'g:brand.0' => $linkdata['brand'],
'g:condition.0' => 'new',
'g:mpn.0' => $linkdata['mpn'],
'g:image_link' => $linkdata['img'],
'g:product_type.0' => $linkdata['ptype'],
'g:payment_accepted.0' => 'AmericanExpress',
'g:payment_accepted.1' => 'Cash',
'g:payment_accepted.2' => 'Check',
'g:payment_accepted.3' => 'Discover',
'g:payment_accepted.4' => 'MasterCard',
'g:payment_accepted.5' => 'Visa',
'g:payment_accepted.6' => 'wiretransfer',
'g:payment_notes.0' => 'All card payments through PayPal or Nochex. Alternatively through PayOffline using the Post Office or any branch of the Alliance & Leicester building society with a variety of payment methods, including cash and cards. Wire transfer payments only in the form of BACs or IBT payments.');
}
...and $linkdata needs to be in the following format (which could vary considerably in length depending on how deep the ptype is within the category tree):
Assorted Gadgets > Bells & Whistles > Various Widgets
This is not a problem because, for the application I am trying to modify, I would make the ptype value Various Widgets, and would then append the rest of the category tree entries to the output value in order to simplify things. The additional category tree values would also all be known values, so the best way to handle this would definitely seem to be having all the category tree values in an array with some kind of merging with the $linkdata value.
The problem is in appending Assorted Gadgets > Bells & Whistles > to the Various Widgets value when output by $linkdata ...and that I what I need some advice with, - what method would work best and how to implement it, etc.?
- I have experimented using an array with str_replace using $before = array() and $after = array() values, but I was unable to get that setup to work.